home *** CD-ROM | disk | FTP | other *** search
- ' +--------------------------------------------------------------+
- ' | Ultra-Graph |
- ' | v1.02 |
- ' | by |
- ' | Phil Mast & Blake Arnold |
- ' +--------------------------------------------------------------+
- ' | GFA Basic 3.0 conversion |
- ' | 11-19-88 |
- ' +--------------------------------------------------------------+
- ' | Featured in the November, 1988 issue of ST-Log Magazine |
- ' +--------------------------------------------------------------+
- '
- GOSUB main
- PROCEDURE main
- ' =========================-Initialize-==========================
- CLS
- IF FRE(0)<225000
- ALERT 3,"Error: Not enough|free memory to run|Ultra-Graph.|(220K free required)",1,"Ok",dum%
- ALERT 1,"|Current free memory |is only "+STR$(CINT(FRE(0)/1024))+"K. ",1,"Ok",dum%
- EDIT
- ENDIF
- scrn|=0
- p_file$="PM-1.00"
- funct_error%=99999999
- boot!=TRUE
- kolor!=FALSE
- off|=0
- LET on|=1
- lo|=0
- med|=1
- hi|=2
- ' Store original color palette
- DIM s_colr&(15,2)
- FOR i%=0 TO 15
- DPOKE CONTRL,26
- DPOKE CONTRL+2,0
- DPOKE CONTRL+6,2
- DPOKE INTIN,i%
- DPOKE INTIN+2,0
- VDISYS
- s_colr&(i%,0)=DPEEK(INTOUT+2)
- s_colr&(i%,1)=DPEEK(INTOUT+4)
- s_colr&(i%,2)=DPEEK(INTOUT+6)
- NEXT i%
- res|=XBIOS(4) !Get the resolution
- ' Allow more points to be plotted if more memory is present
- IF FRE(0)>350000
- max_pts|=99
- ELSE
- max_pts|=60
- ENDIF
- DIM px#(max_pts|,max_pts|),py#(max_pts|,max_pts|),pz#(max_pts|,max_pts|),type$(5),sav_colr%(1)
- DIM pntint_x%(5),pntint_y%(5),minx#(5),miny#(5),maxx#(5),maxy#(5),cx%(5),cy%(5),z%(5),ex%(5),ey%(5),ez%(5)
- DIM function$(5,20),equat%(5),max_limit#(5),min_limit#(5),colrtable|(15)
- DIM n%(10),const#(5,10),paramx$(5),paramy$(5),paramz$(3),lintx%(5),linty%(5)
- DIM rgb%(2),cfunctlabel$(5),postfix$(5),custom_funct!(5)
- DIM numer_val#(30),priority%(100),stack#(30),stack_priority%(30),x%(4),y%(4)
- DIM ed_surface#(max_pts|*max_pts|),pnt_no%(max_pts|*max_pts|)
- IF res|=lo|
- max_sx&=320 !Max & min values for different res's
- max_sy&=200
- ar#=6/7 ! Values to make circles look round in all resolutions
- rxf|=1 !set scale factors for different resolutions
- ryf|=1
- rtxt|=13
- rtxt1|=6
- sclear|=34
- ELSE IF res|=med|
- max_sx&=640
- max_sy&=200
- ar#=2/5
- rxf|=2
- ryf|=1
- rtxt|=13
- rtxt1|=6
- sclear|=68
- ELSE IF res|=hi|
- max_sx&=640
- max_sy&=400
- ar#=1
- rxf|=2
- ryf|=2
- rtxt|=32
- rtxt1|=13
- sclear|=68
- ENDIF
- ' Menu data
- ' --------
- DIM d$(44)
- d$(0)="Desk"
- d$(1)=" About Ultra-Graph "
- d$(2)="-------------------"
- d$(3)="-" ! "-" disables that menu item (disables ACC's here)
- d$(4)="-"
- d$(5)="-"
- d$(6)="-"
- d$(7)="-"
- d$(8)="-"
- d$(9)="" !menus are seperated by a null
- d$(10)="File"
- d$(11)=" NeoChrome Save "
- d$(12)=" Degas Save "
- d$(13)=" Cad-3D Save "
- d$(14)="-----------------"
- d$(15)=" Save Parameters "
- d$(16)=" Load Parameters "
- d$(17)="-----------------"
- d$(18)=" Quit "
- d$(19)=""
- d$(20)="Options"
- d$(21)=" B/W Swap "
- d$(22)=" Gradient "
- d$(23)=" Rainbow "
- d$(24)=" Elevation "
- d$(25)=" Fill Pattern "
- d$(26)="---------------"
- d$(27)=" Grid Lines "
- d$(28)=" Hidden Lines "
- d$(29)=" Draw Axes "
- d$(30)=" Auto-Center "
- d$(31)=" Auto-Scale "
- d$(32)="---------------"
- d$(33)=" Graph it! "
- d$(34)="---------------"
- d$(35)=" Demo Mode "
- d$(36)=" Defaults "
- d$(37)=""
- d$(38)="System"
- d$(39)=" Cartesian "
- d$(40)=" Polar "
- d$(41)=" Rectangular "
- d$(42)=" Cylindrical "
- d$(43)=" Spherical "
- d$(44)=""
- type$(1)="Spherical"
- type$(2)="Rectangular"
- type$(3)="Cylindrical"
- type$(4)="Cartesian"
- type$(5)="Polar"
- sphere|=1
- rect|=2
- cylin|=3
- cart|=4
- polar|=5
- SGET screen1$
- colrtable|(0)=0
- colrtable|(1)=2
- colrtable|(2)=3
- colrtable|(3)=6
- colrtable|(4)=4
- colrtable|(5)=7
- colrtable|(6)=5
- colrtable|(7)=8
- colrtable|(8)=9
- colrtable|(9)=10
- colrtable|(10)=11
- colrtable|(11)=14
- colrtable|(12)=12
- colrtable|(13)=15
- colrtable|(14)=13
- colrtable|(15)=1
- IF res|=med|
- colrtable|(3)=1
- ELSE IF res|=hi|
- colrtable|(1)=1
- ENDIF
- ' x
- paramx$(cart|)="X"
- paramx$(polar|)="Θ"
- paramx$(rect|)="X"
- paramx$(sphere|)="ϕ"
- paramx$(cylin|)="Θ"
- ' y
- paramy$(cart|)="Y"
- paramy$(polar|)="R"
- paramy$(rect|)="Y"
- paramy$(sphere|)="Θ"
- paramy$(cylin|)="Z"
- ' z
- paramz$(rect|)="Z"
- paramz$(sphere|)="R"
- paramz$(cylin|)="R"
- ' ϕ=control-s+m Θ=control-s+I
- ' display functions (not used for calculations!)
- ' CAPITAL letters are VARIABLES; DO NOT capitalize anything else!
- ' Spherical
- function$(sphere|,0)="r=A+B*sqr(C*cos(D*ϕ))"
- function$(sphere|,1)="r=A+B*sin(C*ϕ/D)"
- function$(sphere|,2)="r=A+B*sqr(C*ϕ)"
- function$(sphere|,3)="r=A+B/cos(ϕ)"
- function$(sphere|,4)="r=A+B*sin(C*Θ)"
- function$(sphere|,5)="r=A*sin(B*ϕ)+C*cos(D*Θ)"
- function$(sphere|,6)="r=A*sin(B*ϕ)/(C*cos(ϕ)+1)"
- function$(sphere|,7)="r=A*sin(B*ϕ)+C*cos(D*ϕ)+E"
- function$(sphere|,8)="r=A/(B-C*cos(D*(ϕ)))+E"
- function$(sphere|,9)="r=A/(B-C*sin(D*(ϕ)))+E"
- function$(sphere|,10)="r=A*sin(B*Θ)+C*cos(D*ϕ)"
- function$(sphere|,11)="r=A*sin(exp(ϕ))+B*cos(exp(ϕ))"
- function$(sphere|,12)="r=A*ϕ+B*Θ"
- ' Rectangular
- function$(rect|,0)="z=(A*x^2+B*y^2)*exp(1-C*x^2-D*y^2)"
- function$(rect|,1)="z=A/sqr(B+x^2+y^2)*cos(sqr(C*y^2+D*x^2))"
- function$(rect|,2)="z=(A*X*Y)^(1/B)"
- function$(rect|,3)="z=A*sin(B*x)+C*cos(D*y)"
- function$(rect|,4)="z=A*cos(B*x*C*y)"
- function$(rect|,5)="z=A*(exp(B*sin(C*x*D*y)))"
- function$(rect|,6)="z=A*(abs(B*cos(C*x)+D*cos(E*y)))"
- function$(rect|,7)="z=A*(sqr(B*x^C+D*y^E))"
- function$(rect|,8)="z=1/(A+x^2+y^2)-1/(B+x^2+(y-2)^2)"
- function$(rect|,9)="z=(x^2*cos(A*x)+y^2*B*sin(C*y))*exp(1-x^2-y^2)"
- function$(rect|,10)="z=A*log(abs(B*x))+C*log(abs(D*y))"
- function$(rect|,11)="z=sin(A*x)*cos(B*y)"
- function$(rect|,12)="z=A*cos(sqr(B*x^2+C*y^2))+D*cos(x)"
- ' Cylindrical
- function$(cylin|,0)="r=A+B*cos(C*Θ)+D*sin(E*Θ)"
- function$(cylin|,1)="r=A/(B-C*cos(D*Θ))+E"
- function$(cylin|,2)="r=A*sin(B*Θ)+C*cos(D*Θ)+E*z"
- function$(cylin|,3)="r=A+B*sin(C*Θ)*cos(D*Θ)"
- function$(cylin|,4)="r=A+B*tan(C*Θ)"
- function$(cylin|,5)="r=A+B*sin(C*Θ)*(cos(D*Θ))^2"
- function$(cylin|,6)="r=A+B*z-C*sin(D*z)"
- function$(cylin|,7)="r=A*z^2+B*z+C"
- function$(cylin|,8)="r=A/z^2+B/z+C"
- function$(cylin|,9)="r=A+B*z+C*z*cos(D*Θ)"
- function$(cylin|,10)="r=sin(A*z)*cos(B*Θ)"
- ' Cartesian
- function$(cart|,0)="y=A*x^3+B*x^2+C*x+D"
- function$(cart|,1)="y=(A/sqr(2*Pi))*exp(-x^2/2)"
- function$(cart|,2)="y=x/A+x^B-x^C"
- function$(cart|,3)="y=A+B*sin(C*x)+D*x*(sin(E*x))"
- function$(cart|,4)="y=A+B*cos(C*x)+D*x*(cos(E*x))"
- function$(cart|,5)="y=A+B*tan(C*x)+D*x*(tan(E*x))"
- function$(cart|,6)="y=A+B*1/cos(C*x)+D*x*1/cos(E*x)"
- function$(cart|,7)="y=A+B*sin(C*x)+D*x*(cos(E*x))"
- function$(cart|,8)="y=A+B*(exp(x)-exp(-x))/2+C*(exp(x)+exp(-x))/2"
- function$(cart|,9)="y=A*sqr(B^2-x^2)"
- function$(cart|,10)="y=(A*x-2)^3/(B*x^2)"
- function$(cart|,11)="y=A*x^2/exp(B*x)"
- function$(cart|,12)="y=cos(A*x)*exp(x/B)"
- function$(cart|,13)="y=A*x^3*exp(-x/B)"
- function$(cart|,14)="y=A*x/(B*x+C)^2"
- function$(cart|,15)="y=A*atn(x)"
- ' Polar
- function$(polar|,0)="r=A+B*cos(C*Θ)+D*sin(E*Θ)"
- function$(polar|,1)="r=A+B*sqr(C*cos(D*Θ))"
- function$(polar|,2)="r=A/(B-C*cos(D*Θ))+E"
- function$(polar|,3)="r=A/(B-C*sin(D*Θ))+E"
- function$(polar|,4)="r=A+B*tan(C*Θ)"
- function$(polar|,5)="r=A+B*sin(C*Θ)*tan(D*Θ)"
- function$(polar|,6)="r=A/Θ"
- function$(polar|,7)="r=A+B*sin(C*Θ)*cos(D*Θ)"
- function$(polar|,8)="r=A+B/sin(C*Θ)"
- function$(polar|,9)="r=A+B*sin(C*Θ)*(cos(D*Θ))^2"
- ' ----------
- GOSUB defaults
- MENU d$()
- MENU OFF
- GOSUB mark_menu
- ' Let the program know where to go on a drop-down selection
- ON MENU GOSUB set_options
- ' ----Main Loop for the option menu----
- DO
- ON MENU
- dum%=MOUSEK
- IF dum%=2
- GOSUB screenswap
- ELSE IF dum%=1 ! AND MENU(9)<>32 ! if menu(9)=32 then a drop-down is selected
- GOSUB chg_params
- ELSE IF dum%=3
- GOSUB start
- SGET screen1$
- ENDIF
- LOOP
- RETURN
- PROCEDURE set_options
- ' OOOOOOOOOOOOOOOOOOOOOOOOOOO-Set Options-OOOOOOOOOOOOOOOOOOOOOOOOOOO
- ' Drop-down menu selections
- MENU OFF
- IF d$(MENU(0))=d$(1) ! About Ultra-Graph
- GOSUB credits
- ELSE IF d$(MENU(0))=d$(11) ! Save Picture
- IF graph!=TRUE
- extender$=".NEO"
- choice|=2
- GOSUB open_file
- ELSE
- ALERT 3,"|No Graph to Save!",1,"Ok",dum%
- ENDIF
- ELSE IF d$(MENU(0))=d$(12) ! Save Picture
- IF graph!=TRUE
- extender$=".PI"+STR$(res|+1)
- choice|=1
- GOSUB open_file
- ELSE
- ALERT 3,"|No Graph to Save!",1,"Ok",dum%
- ENDIF
- ELSE IF d$(MENU(0))=d$(13) ! CAD-3D Save
- IF graph!=TRUE
- o_name$=STRING$(9,"_")
- PRINT AT(6,22);"Object Name: ";
- FORM INPUT 8,temp$
- temp$=temp$+MKI$(0)
- MID$(o_name$,1,LEN(temp$)-1)=temp$
- POKE VARPTR(o_name$)+8,0
- GOSUB clearit_all
- PRINT AT(6,22);"Double Sided (Y/N)? ";
- temp$=CHR$(INP(2))
- IF UPPER$(temp$)="N"
- dble!=FALSE
- ELSE
- dble!=TRUE
- ENDIF
- GOSUB clearit_all
- IF NOT dble!
- IF izhi%=pntint_x%(type|)
- DEC izhi%
- ENDIF
- IF jzhi%=pntint_y%(type|)
- DEC jzhi%
- ENDIF
- a1#=px#(izhi%+1,jzhi%+1)-px#(izhi%,jzhi%+1)
- a2#=py#(izhi%+1,jzhi%+1)-py#(izhi%,jzhi%+1)
- b1#=px#(izhi%,jzhi%+1)-px#(izhi%,jzhi%)
- b2#=py#(izhi%,jzhi%+1)-py#(izhi%,jzhi%)
- IF ABS(osurface1#)<1E-05
- a1#=px#(izhi%,jzhi%)-px#(izhi%+1,jzhi%)
- a2#=py#(izhi%,jzhi%)-py#(izhi%+1,jzhi%)
- b1#=px#(izhi%+1,jzhi%)-px#(izhi%+1,jzhi%+1)
- b2#=py#(izhi%+1,jzhi%)-py#(izhi%+1,jzhi%+1)
- ENDIF
- osurface#=a1#*b2#-a2#*b1#
- IF SGN(osurface#)=-1
- side1!=TRUE
- side2!=FALSE
- ELSE
- side2!=TRUE
- side1!=FALSE
- ENDIF
- ELSE
- side1!=TRUE
- side2!=TRUE
- ENDIF
- GOSUB clearit_all
- extender$=".3D2"
- choice|=4
- GOSUB open_file
- ELSE
- ALERT 3,"|No object to save!",1,"Ok",dum%
- ENDIF
- ELSE IF d$(MENU(0))=d$(15) ! Save Parameters
- extender$=".PM"+STR$(res|+1)
- choice|=3
- GOSUB open_file
- ELSE IF d$(MENU(0))=d$(16) ! Load Parameters
- choice|=5
- extender$=".PM?"
- GOSUB open_file
- IF type|=cart| OR type|=polar|
- GOSUB change_2d
- ELSE
- GOSUB change_3d
- ENDIF
- IF custom_funct!(type|)=TRUE
- GOSUB convert
- ENDIF
- IF VAL(RIGHT$(filename$))<>res|+1
- a_ctr|=on|
- a_scl|=on|
- ELSE
- a_ctr|=off|
- a_scl|=off|
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(18) ! Quit
- ALERT 2,"| Quit Ultra-Graph? ",1,"Yes|No ",dum%
- IF dum%=1
- CLS
- ' Restore original color palette
- FOR i%=0 TO 15
- DPOKE CONTRL,14
- DPOKE CONTRL+2,0
- DPOKE CONTRL+6,4
- DPOKE INTIN,i%
- DPOKE INTIN+2,s_colr&(i%,0)
- DPOKE INTIN+4,s_colr&(i%,1)
- DPOKE INTIN+6,s_colr&(i%,2)
- VDISYS
- NEXT i%
- MENU KILL
- MENU OFF
- EDIT
- ENDIF
- ELSE IF d$(MENU(0))=d$(21) ! B/W Swap
- IF palette|<>4
- palette|=4 !White on black
- IF res|=lo|
- SETCOLOR 0,7,7,7
- SETCOLOR 15,0,0,0
- ELSE IF res|=hi|
- SETCOLOR 0,0,0,0
- SETCOLOR 1,7,7,7
- ELSE IF res|=med|
- SETCOLOR 0,7,7,7
- SETCOLOR 3,0,0,0
- ENDIF
- ELSE
- palette|=0 !Black on white (normal screen)
- IF res|=lo|
- SETCOLOR 15,7,7,7
- SETCOLOR 0,0,0,0
- ELSE IF res|=hi|
- SETCOLOR 0,7,7,7
- SETCOLOR 1,0,0,0
- ELSE IF res|=med|
- SETCOLOR 0,0,0,0
- SETCOLOR 3,7,7,7
- ENDIF
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(22) ! Gradient
- ALERT 2,"| Which Color? ",1,"R|G|B",palette|
- GOSUB palette
- ELSE IF d$(MENU(0))=d$(23) ! Rainbow
- palette|=5
- GOSUB palette
- ELSE IF d$(MENU(0))=d$(24) ! Elevation
- palette|=6
- GOSUB palette
- ELSE IF d$(MENU(0))=d$(25) ! Fill Pattern
- GOSUB get_pattern
- ELSE IF d$(MENU(0))=d$(27) ! Grid Lines
- IF grid_lines|=off|
- grid_lines|=on|
- axes|=off|
- ELSE
- grid_lines|=off|
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(28) ! Hidden Lines
- IF hide_lines|=off|
- hide_lines|=on|
- ELSE
- hide_lines|=off|
- ENDIF
- GOSUB mark_menu
- GOSUB lint
- ELSE IF d$(MENU(0))=d$(29) ! Draw Axes
- IF axes|=off|
- axes|=on|
- grid_lines|=off|
- ELSE
- axes|=off|
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(30) ! Auto Center
- IF a_ctr|=on|
- a_ctr|=off|
- ELSE
- a_ctr|=on|
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(31) ! Auto Scale
- IF a_scl|=on|
- a_scl|=off|
- ELSE
- a_scl|=on|
- ENDIF
- GOSUB mark_menu
- ELSE IF d$(MENU(0))=d$(33) ! Graph it
- GOSUB start
- SGET screen1$
- ELSE IF d$(MENU(0))=d$(35) ! Demo Mode
- ALERT 1," | To exit Demo Mode,| push ESCAPE after | a graph is drawn. ",1," Demo |Cancel",dum%
- IF dum%=1
- GOSUB do_demo
- ENDIF
- ELSE IF d$(MENU(0))=d$(36) ! Defaults
- ALERT 2,"| Restore Defaults? ",2,"Yes|No",dum%
- IF dum%=1
- ERASE px#()
- ERASE py#()
- ERASE pz#()
- DIM px#(max_pts|,max_pts|),py#(max_pts|,max_pts|),pz#(max_pts|,max_pts|)
- CLS
- GOSUB defaults
- GOSUB mark_menu
- ENDIF
- ELSE IF d$(MENU(0))=d$(39) ! Cartesian
- type|=cart|
- GOSUB change_2d
- ELSE IF d$(MENU(0))=d$(40) ! Polar
- type|=polar|
- GOSUB change_2d
- ELSE IF d$(MENU(0))=d$(41) ! Rectangular
- type|=rect|
- GOSUB change_3d
- ELSE IF d$(MENU(0))=d$(42) ! Cylindrical
- type|=cylin|
- GOSUB change_3d
- ELSE IF d$(MENU(0))=d$(43) ! Spherical
- type|=sphere|
- GOSUB change_3d
- ENDIF
- RETURN
- PROCEDURE change_2d
- ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-2D/3D-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- MENU KILL
- three_d!=FALSE
- cf!=TRUE
- axes|=off|
- kolor!=FALSE
- ERASE px#()
- ERASE py#()
- ERASE pz#()
- DIM px#(0,999),py#(0,999),pz#(0,999)
- GOSUB mark_menu
- GOSUB palette
- GOSUB getconst
- IF demo|=on|
- title!=TRUE
- ELSE
- title!=FALSE
- ENDIF
- GOSUB param_menu
- title!=TRUE
- RETURN
- PROCEDURE change_3d
- MENU KILL
- three_d!=TRUE
- cf!=TRUE
- ERASE px#()
- ERASE py#()
- ERASE pz#()
- DIM px#(max_pts|,max_pts|),py#(max_pts|,max_pts|),pz#(max_pts|,max_pts|)
- GOSUB palette
- GOSUB getconst
- IF demo|=on|
- title!=TRUE
- ELSE
- title!=FALSE
- ENDIF
- GOSUB param_menu
- title!=TRUE
- RETURN
- PROCEDURE mark_menu
- ' %%%%%%%%%%%%%%%%%%%-Set Menu Checks (markit)-%%%%%%%%%%%%%%%%%%%%
- ' set the check-marks on the drop-downs
- IF NOT three_d!
- MENU 13,2
- MENU 22,2
- MENU 23,2
- MENU 24,2
- MENU 25,2
- MENU 27,3
- MENU 28,2
- MENU 29,3
- IF grid_lines|=on|
- MENU 29,2
- ENDIF
- IF axes|=on|
- MENU 27,2
- ENDIF
- ELSE
- MENU 13,3
- MENU 22,3
- MENU 23,3
- MENU 24,3
- MENU 25,3
- MENU 27,2
- MENU 28,3
- ENDIF
- IF res|=lo|
- IF palette|=0 OR palette|=4
- MENU 21,1 ! 1 puts a check by the menu item
- MENU 22,0 ! 0 removes a check
- MENU 23,0
- MENU 24,0
- ELSE IF palette|=1 OR palette|=2 OR palette|=3
- MENU 21,0
- MENU 22,1
- MENU 23,0
- MENU 24,0
- ELSE IF palette|=5
- MENU 21,0
- MENU 22,0
- MENU 23,1
- MENU 24,0
- ELSE IF palette|=6
- MENU 21,0
- MENU 22,0
- MENU 23,0
- MENU 24,1
- ENDIF
- ELSE
- MENU 11,2 !Void NeoChrome save
- MENU 22,2 !Void Color Palettes
- MENU 23,2
- MENU 24,2
- ENDIF
- IF type|=4
- MENU 39,1
- MENU 40,0
- MENU 41,0
- MENU 42,0
- MENU 43,0
- ELSE IF type|=5
- MENU 39,0
- MENU 40,1
- MENU 41,0
- MENU 42,0
- MENU 43,0
- ELSE IF type|=2
- MENU 39,0
- MENU 40,0
- MENU 41,1
- MENU 42,0
- MENU 43,0
- ELSE IF type|=3
- MENU 39,0
- MENU 40,0
- MENU 41,0
- MENU 42,1
- MENU 43,0
- ELSE IF type|=1
- MENU 39,0
- MENU 40,0
- MENU 41,0
- MENU 42,0
- MENU 43,1
- ENDIF
- MENU 27,grid_lines|
- MENU 28,hide_lines|
- MENU 29,axes| !since these values can only be 0 or 1 we can get away
- MENU 30,a_ctr| !with this
- MENU 31,a_scl|
- RETURN
- PROCEDURE credits
- ' ********************** - Credits box - ***********************
- CLS
- IF res|=lo|
- pfx&=0
- pfy&=0
- ELSE IF res|=med|
- pfx&=160
- pfy&=0
- ELSE IF res|=hi|
- pfx&=160
- pfy&=90
- ENDIF
- ~FORM_DIAL(1,0,0,0,0,9+pfx&,10+pfy&,311,191)
- ' Fake a huge ALERT box so we can squeeze in all the credits.
- COLOR colrtable|(1)
- DEFLINE 1,1
- ' "Defline 1,2" doesn't seem to work (the line ends up 3 pixels wide), so we
- ' fake that, too
- ' main box
- BOX 9+pfx&,9+pfy&,311+pfx&,191+pfy&
- BOX 10+pfx&,10+pfy&,310+pfx&,190+pfy&
- DEFLINE 1,1
- BOX 13+pfx&,13+pfy&,306+pfx&,187+pfy&
- ' text
- DEFTEXT 3,9,0,19
- TEXT 94+pfx&,35+pfy&,"Ultra-Graph"
- DEFTEXT 1,0,0,4
- TEXT 137+pfx&,70+pfy&,"and"
- TEXT 118+pfx&,45+pfy&,"Copyright 1988"
- ' TEXT 85+pfx&,99+pfy&,"(Available from MichTron)"
- DEFTEXT 1,0,0,6
- TEXT 150+pfx&,57+pfy&,"By"
- TEXT 66+pfx&,90+pfy&,"Programmed in"
- TEXT 100+pfx&,120+pfy&,"Available from:"
- TEXT 38+pfx&,152+pfy&,"9171 Wilshire Blvd., Suite 300"
- TEXT 68+pfx&,163+pfy&,"Beverly Hills, CA 90210"
- DEFTEXT 3,1,0,7
- TEXT 41+pfx&,70+pfy&,"Phil Mast"
- TEXT 166+pfx&,70+pfy&,"Blake Arnold"
- DEFTEXT 1,1,0,6
- TEXT 179+pfx&,90+pfy&,"GFA Basic"
- DEFTEXT 3,4,0,15
- TEXT 95+pfx&,140+pfy&,"ST-Log"
- DEFTEXT 3,4,0,6
- TEXT 161+pfx&,140+pfy&,"Magazine"
- DEFTEXT 2,0,0,4
- TEXT 274+pfx&,184+pfy&,"v1.02"
- ' are we having fun yet?
- IF boot!=FALSE
- DEFLINE 1,1,0,0
- BOX 134+pfx&,169+pfy&,182+pfx&,181+pfy&
- BOX 133+pfx&,168+pfy&,183+pfx&,182+pfy&
- DEFTEXT 1,0,0,6
- TEXT 150+pfx&,178+pfy&,"Ok"
- DO
- MOUSE micex&,micey&,dum%
- IF (micey&>168+pfy& AND micey&<182+pfy&) AND (micex&>133+pfx& AND micex&<183+pfx&) AND dum%=1
- GOTO done_box
- ENDIF
- EXIT IF INKEY$=CHR$(13)
- LOOP
- done_box:
- ' To complete the illusion of an ALERT box, we even fill the "Ok" box as
- ' GEM would do.
- DEFFILL 2,2,8
- PBOX 133+pfx&,168+pfy&,183+pfx&,182+pfy&
- IF res|=lo| OR res|=med|
- DEFTEXT 1,0,0,6
- ELSE
- DEFTEXT 1,0,0,13
- ENDIF
- CLS
- title!=TRUE
- ~FORM_DIAL(2,0,0,0,0,9+pfx&,10+pfy&,311,191)
- GOSUB param_menu !Reprint the menu screen
- PAUSE 30
- ELSE
- PAUSE 150
- CLS
- ~FORM_DIAL(2,0,0,0,0,9+pfx&,10+pfy&,311,191)
- ENDIF
- title!=TRUE
- RETURN
- PROCEDURE do_demo
- ' dddddddddddddddddddddddddddddd- DEMO -dddddddddddddddddddddddddddd
- dum%=1
- ' Next rem should be active as a statement in compiled (2.02) version only
- ' Alert 2,"|Demo exits to bombs.| Continue? ",1,"Yes| No",Dum%
- IF dum%<>2
- demo|=on|
- GOSUB defaults
- DEFMOUSE 2
- REPEAT
- jj%=0
- REPEAT
- type|=sphere|
- REPEAT
- CLS
- equat%(type|)=jj%
- IF type|=cart| OR type|=polar|
- GOSUB change_2d
- ELSE
- GOSUB change_3d
- ENDIF
- PAUSE 100
- cf!=TRUE
- GOSUB start
- SGET screen1$
- FOR i%=1 TO 200
- PAUSE 1
- temp$=INKEY$
- EXIT IF temp$=CHR$(27)
- NEXT i%
- INC type|
- UNTIL type|=6 OR temp$=CHR$(27)
- type|=1
- INC jj%
- UNTIL jj%=10 OR temp$=CHR$(27)
- UNTIL temp$=CHR$(27)
- CLS
- demo|=off|
- GOSUB defaults
- DEFMOUSE 0
- SHOWM
- ENDIF
- RETURN
- PROCEDURE defaults
- ' ###########################-Defaults-############################
- VOID FRE(0)
- three_d!=TRUE
- ptrn|=8
- trig!=FALSE
- title!=TRUE
- graph!=FALSE
- ' Axes OFF, Auto-center ON, Auto-Scale ON, Hidden Lines ON, Grid Lines ON
- grid_lines|=on|
- hide_lines|=on|
- axes|=off|
- a_ctr|=on|
- a_scl|=on|
- cf!=TRUE !Function change flag
- IF res|=lo|
- SETCOLOR 0,0,0,0
- SETCOLOR 15,7,7,7
- ELSE IF res|=hi|
- SETCOLOR 0,7,7,7
- SETCOLOR 1,0,0,0
- ELSE IF res|=med|
- SETCOLOR 3,7,7,7
- SETCOLOR 0,0,0,0
- ENDIF
- IF res|<>hi|
- FOR i%=1 TO 5
- z%(i%)=80
- NEXT i%
- palette|=5
- GOSUB palette
- ELSE
- FOR i%=1 TO 5
- z%(i%)=120
- NEXT i%
- ENDIF
- FOR i%=1 TO 5
- cx%(i%)=max_sx&/2
- cy%(i%)=max_sy&/2
- custom_funct!(i%)=FALSE
- NEXT i%
- ' set initial constant values to 1 for all functions
- FOR i%=1 TO 5
- FOR j%=1 TO 10
- const#(i%,j%)=1
- NEXT j%
- NEXT i%
- minx#(rect|)=-3
- maxx#(rect|)=3
- miny#(rect|)=-3
- maxy#(rect|)=3
- minx#(sphere|)=PI
- maxx#(sphere|)=2*PI
- miny#(sphere|)=0
- maxy#(sphere|)=2*PI
- minx#(cylin|)=0
- maxx#(cylin|)=2*PI
- miny#(cylin|)=0
- maxy#(cylin|)=3
- minx#(cart|)=-3.14
- maxx#(cart|)=3.14
- FOR i%=1 TO 5
- max_limit#(i%)=4
- min_limit#(i%)=-4
- lintx%(i%)=1
- linty%(i%)=1
- pntint_x%(i%)=25
- pntint_y%(i%)=25
- ex%(i%)=20
- ey%(i%)=25
- ez%(i%)=15
- NEXT i%
- pntint_x%(cart|)=0
- pntint_y%(cart|)=max_sx&-20
- x_int#=0.5
- y_int#=0.5
- ex%(cart|)=9999
- ey%(cart|)=0
- ez%(cart|)=0
- minx#(polar|)=0
- maxx#(polar|)=2*PI
- pntint_x%(polar|)=0
- pntint_y%(polar|)=max_sx&-20
- ex%(polar|)=9999
- ey%(polar|)=0
- ez%(polar|)=0
- type|=rect| !intial type
- GOSUB getconst !get everything fired up and ready to go (sets variables)
- IF boot!=TRUE
- SETCOLOR 1,0,0,6
- SETCOLOR 2,0,7,1
- COLOR colrtable|(1)
- HIDEM
- GOSUB credits
- SHOWM
- CLS
- ' Draw and save main menu border
- DEFLINE 1,4,0,0
- DEFFILL colrtable|(2),2,8
- COLOR colrtable|(1)
- BOX 5*rxf|,19*ryf|,316*rxf|,195*ryf|
- IF res|=lo|
- DRAW 3*rxf|,19*ryf| TO 4*rxf|,19*ryf|
- ELSE
- DRAW 4*rxf|,19*ryf| TO 5*rxf|,19*ryf|
- ENDIF
- DEFLINE 1,1,0,0
- BOX 11*rxf|,23*ryf|,310*rxf|,191*ryf|
- IF res|<>hi|
- FILL 160*rxf|,21*ryf|
- ENDIF
- DEFLINE 1,1,0,0
- BOX 15*rxf|,162*ryf|,306*rxf|,187*ryf|
- LINE 11*rxf|,158*ryf|,310*rxf|,158*ryf|
- DEFTEXT colrtable|(2),16,0,rtxt|
- IF res|<>1
- TEXT 100*rxf|,26*ryf|,"Ultra-Graph"
- DEFTEXT 1,0,0,rtxt1|
- ELSE
- TEXT 260,26,"Ultra-Graph"
- ENDIF
- IF res|<>hi|
- DEFFILL colrtable|(1),2,8
- ELSE
- DEFFILL colrtable|(0),2,8
- ENDIF
- COLOR colrtable|(15)
- PBOX 25*rxf|,47*ryf|,31*rxf|,53*ryf|
- BOX 25*rxf|,47*ryf|,31*rxf|,53*ryf|
- PBOX 25*rxf|,65*ryf|,31*rxf|,71*ryf|
- BOX 25*rxf|,65*ryf|,31*rxf|,71*ryf|
- PBOX 25*rxf|,75*ryf|,31*rxf|,81*ryf|
- BOX 25*rxf|,75*ryf|,31*rxf|,81*ryf|
- PBOX 25*rxf|,93*ryf|,31*rxf|,99*ryf|
- BOX 25*rxf|,93*ryf|,31*rxf|,99*ryf|
- PBOX 25*rxf|,103*ryf|,31*rxf|,109*ryf|
- BOX 25*rxf|,103*ryf|,31*rxf|,109*ryf|
- PBOX 25*rxf|,113*ryf|,31*rxf|,119*ryf|
- BOX 25*rxf|,113*ryf|,31*rxf|,119*ryf|
- PBOX 25*rxf|,123*ryf|,31*rxf|,129*ryf|
- BOX 25*rxf|,123*ryf|,31*rxf|,129*ryf|
- PBOX 25*rxf|,133*ryf|,31*rxf|,139*ryf|
- BOX 25*rxf|,133*ryf|,31*rxf|,139*ryf|
- PBOX 25*rxf|,143*ryf|,31*rxf|,149*ryf|
- BOX 25*rxf|,143*ryf|,31*rxf|,149*ryf|
- SGET mscreen$
- ENDIF
- boot!=FALSE
- GOSUB param_menu
- RETURN
- PROCEDURE palette
- ' ++++++++++++++++++++++++++++-Palette-++++++++++++++++++++++++++++
- IF res|=lo|
- IF palette|<>4
- IF palette|=1
- RESTORE red
- ELSE IF palette|=2
- RESTORE green
- ELSE IF palette|=3
- RESTORE blue
- ELSE IF palette|=5
- RESTORE rainbow
- ELSE
- RESTORE elevation
- ENDIF
- IF three_d!=FALSE
- RESTORE twod
- ENDIF
- FOR i%=0 TO 15
- READ colr%
- IF i%=1 OR i%=2
- sav_colr%(i%-1)=colr%
- ELSE
- SETCOLOR i%,colr%
- ENDIF
- NEXT i%
- ENDIF
- rainbow:
- DATA &000,&700,&730,&751,&770,&561,&360,&051,&054,&045,&226,&305,&404,&514,&716,&777
- elevation:
- DATA &000,&776,&775,&764,&653,&553,&453,&243,&244,&345,&246,&236,&125,&115,&004,&777
- red:
- DATA &000,&755,&744,&733,&722,&711,&711,&700,&600,&600,&500,&400,&400,&300,&300,&777
- green:
- DATA &000,&575,&474,&373,&272,&171,&070,&060,&060,&050,&040,&040,&030,&030,&020,&777
- blue:
- DATA &000,&557,&447,&337,&227,&117,&117,&007,&006,&006,&005,&004,&004,&003,&003,&777
- twod:
- DATA &000,&750,&400,&047,&555,&117,&117,&007,&006,&006,&005,&004,&004,&003,&003,&777
- ELSE IF res|=med|
- sav_colr%(0)=&H750
- sav_colr%(1)=&H400
- ENDIF
- GOSUB mark_menu
- RETURN
- PROCEDURE start
- ' SSSSSSSSSSSSSSSSSSSSSSSSSSSS-Start-SSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
- VOID FRE(0)
- HIDEM
- graph!=TRUE
- MENU KILL
- MENU OFF
- CLS
- GOSUB graphit
- GOSUB hide_mouse
- RETURN
- PROCEDURE hide_mouse
- ' ---------- Keep the mouse arrow hidden and look for right mouse button-------
- HIDEM
- PAUSE 30
- IF demo|=off|
- DO
- EXIT IF MOUSEK=2
- LOOP
- SHOWM
- ENDIF
- RETURN
- PROCEDURE autocenter
- ' AAAAAAAAAAAAAAAAAAAAAAAAAA-Autocenter-AAAAAAAAAAAAAAAAAAAAAAAAAA
- ON ERROR GOSUB graph_error1
- qx#=px#(ixhi%,jxhi%)
- qy#=py#(ixhi%,jxhi%)
- qz#=pz#(ixhi%,jxhi%)
- GOSUB calcsxsy
- sxhi#=sx#
- qx#=px#(ixlo%,jxlo%)
- qy#=py#(ixlo%,jxlo%)
- qz#=pz#(ixlo%,jxlo%)
- GOSUB calcsxsy
- sxlo#=sx#
- qx#=px#(iyhi%,jyhi%)
- qy#=py#(iyhi%,jyhi%)
- qz#=pz#(iyhi%,jyhi%)
- GOSUB calcsxsy
- syhi#=sy#
- qx#=px#(iylo%,jylo%)
- qy#=py#(iylo%,jylo%)
- qz#=pz#(iylo%,jylo%)
- GOSUB calcsxsy
- sylo#=sy#
- cx%(type|)=INT(cx%(type|)+max_sx&/2-(sxhi#+sxlo#)/2)
- cy%(type|)=INT(cy%(type|)+(max_sy&/2-(syhi#+sylo#)/2)*1/ar#)
- ON ERROR
- auto_cen1:
- RETURN
- PROCEDURE graph_error1
- graph!=FALSE
- PRINT "◆"
- ALERT 1,"|Graph lies outside |the specified range",1,"Oops",dum%
- RESUME auto_cen1
- RETURN
- PROCEDURE autoscale
- ' *************************-Autoscale-***************************
- IF three_d!
- xratio#=(sxhi#-sxlo#)/(max_sx&-20*rxf|)
- yratio#=(syhi#-sylo#)/(max_sy&-20*ryf|)
- ELSE
- xratio#=(sxhi#-sxlo#)/(max_sx&-50*rxf|)
- yratio#=(syhi#-sylo#)/(max_sy&-50*ryf|)
- ENDIF
- ON ERROR GOSUB graph_error
- dum_z#=z%(type|)
- IF xratio#>yratio#
- DIV dum_z#,xratio#
- ELSE
- DIV dum_z#,yratio#
- ENDIF
- z%(type|)=dum_z#
- IF z%(type|)=0
- z%(type|)=1
- ENDIF
- ON ERROR
- autoscl1:
- RETURN
- PROCEDURE graph_error
- PRINT "◆"
- ALERT 1,"|Graph lies outside |the specified range",1,"Oops",dum%
- graph!=FALSE
- RESUME autoscl1
- RETURN
- PROCEDURE calcsxsy
- ' FFFFFFFFFFFFFFFFFFFFFFFFF-Calculate Sx,Sy-FFFFFFFFFFFFFFFFFFFFFF
- ' Calculate the screen coordinates of each point
- SUB qx#,fx#
- SUB qy#,fy#
- SUB qz#,fz#
- ' Project the vectors onto the screen plane
- sx#=qx#*m1#+qy#*m2#+qz#*m3#
- sy#=qx#*m4#+qy#*m5#+qz#*m6#
- sz#=qx#*m7#+qy#*m8#+qz#*m9#
- x#=ed#-sz#
- IF x#<1
- x#=1
- ENDIF
- ADD x#,x#
- t#=(z%(type|)*ed#)/x#
- sx#=t#*sx#+cx%(type|)
- sy#=cy%(type|)-t#*sy#
- MUL sy#,ar#
- RETURN
- PROCEDURE calcsxsyhilo
- ' //////////////////////-Calculate sx sy Hi/Lo-////////////////////
- ' Find the hi & lo values of screen coordinates for autocenter
- firstpass%=1
- FOR i%=0 TO pntint_x%(type|) STEP 2
- FOR j%=0 TO pntint_y%(type|) STEP 2
- qx#=px#(i%,j%)
- qy#=py#(i%,j%)
- qz#=pz#(i%,j%)
- IF pz#(i%,j%)<>funct_error%
- GOSUB calcsxsy
- IF firstpass%=1 !If this is the first time through set initial values
- sxhi#=sx#
- ixhi%=i%
- jxhi%=j%
- sxlo#=sx#
- ixlo%=i%
- jxlo%=j%
- syhi#=sy#
- iyhi%=i%
- jyhi%=j%
- sylo#=sy#
- iylo%=i%
- jylo%=j%
- firstpass%=2
- ENDIF
- IF sx#>sxhi#
- sxhi#=sx#
- ixhi%=i%
- jxhi%=j%
- ENDIF
- IF sx#<sxlo#
- sxlo#=sx#
- ixlo%=i%
- jxlo%=j%
- ENDIF
- IF sy#>syhi#
- syhi#=sy#
- iyhi%=i%
- jyhi%=j%
- ENDIF
- IF sy#<sylo#
- sylo#=sy#
- iylo%=i%
- jylo%=j%
- ENDIF
- ENDIF
- NEXT j%
- NEXT i%
- RETURN
- PROCEDURE graphit
- ' GGGGGGGGGGGGGGGGGGGGGGGGGG-Graph It-GGGGGGGGGGGGGGGGGGGGGGGGGGG
- PRINT CHR$(10)
- IF res|<>hi|
- SETCOLOR 1,sav_colr%(0)
- SETCOLOR 2,sav_colr%(1)
- ENDIF
- IF res|=lo|
- IF palette|<>0 AND palette|<>4 AND three_d!=TRUE
- kolor!=TRUE
- ELSE
- kolor!=FALSE
- ENDIF
- ENDIF
- IF cf!=TRUE !If we haven't changed functions don't need to recalculate points
- IF pntint_x%(type|)<>0
- calc_points%=(pntint_x%(type|)+1)*(pntint_y%(type|)+1)
- ELSE
- calc_points%=pntint_y%(type|)+1
- ENDIF
- PRINT ''"Calculating ";calc_points%;" Points"
- PRINT AT(3,4);"Points Remaining:"
- ON type| GOSUB spheric,rect,cylin,cart,polar
- ' compute color band interval size
- dz1#=(zhi#-zlo#)/14
- IF dz1#=0
- dz1#=1
- ENDIF
- GOSUB form_matrix
- cf!=FALSE
- ENDIF
- IF a_ctr|=on| OR a_scl|=on| OR axes|=on|
- IF a_scl|=on|
- PRINT ''"Auto-scaling"
- ENDIF
- IF a_ctr|=on|
- PRINT ''"Auto-centering"
- ENDIF
- IF axes|=on|
- PRINT ''"Calculating Axes"
- ENDIF
- GOSUB calcsxsyhilo
- IF a_scl|=on|
- GOSUB autoscale
- ENDIF
- IF graph!=FALSE
- GOTO graph_done
- ENDIF
- IF a_ctr|=on|
- GOSUB autocenter
- ENDIF
- IF graph!=FALSE
- GOTO graph_done
- ENDIF
- ENDIF
- CLS
- IF three_d! AND hide_lines|=on|
- PRINT
- PRINT ''"Calculating eye distances"
- GOSUB eye_dist
- PRINT ''"Sorting"
- GOSUB quick_sort
- CLS
- ENDIF
- IF axes|=on|
- GOSUB drwaxes
- ENDIF
- IF grid_lines|=on| AND three_d!=FALSE
- GOSUB drw_grid
- ENDIF
- IF three_d! AND hide_lines|=on|
- GOSUB hidden_lines
- ELSE
- IF lintx%(type|)<>0 !If the line interval is 0 for one axis then skip it
- GOSUB xaxis
- ENDIF
- ENDIF
- IF three_d! AND hide_lines|=off|
- IF linty%(type|)<>0
- GOSUB yaxis
- ENDIF
- ENDIF
- graph_done:
- FOR i#=15 TO 0 STEP -1
- SOUND 1,i#,12,5
- PAUSE 1
- NEXT i#
- RETURN
- PROCEDURE form_matrix
- ' MMMMMMMMMMMMMMMMMMMMMMM-Form the Matrix-MMMMMMMMMMMMMMMMMMMMMMM
- ' Find the midpoint of the graph
- x#=(xlo#+xhi#)/2
- y#=(ylo#+yhi#)/2
- z#=(zlo#+zhi#)/2
- fx#=x#
- fy#=y#
- fz#=z#
- IF NOT three_d! !Position eye perpendicular to graph
- x#=0
- ey%(type|)=y#
- ez%(type|)=z#
- ENDIF
- ' Vectors from eye position to mid point
- m7#=ex%(type|)-fx#
- m8#=ey%(type|)-fy#
- m9#=ez%(type|)-fz#
- IF m9#=0
- m9#=0.0001 !Can't let this be zero
- ENDIF
- ' Calcualte eye distance
- ed#=SQR(ex%(type|)*ex%(type|)+ey%(type|)*ey%(type|)+ez%(type|)*ez%(type|))
- IF ed#=0
- ed#=1 !Don't let it be zero
- ENDIF
- IF NOT three_d!
- ed#=1E+08 !Remove perspective effect from 2-D graphs
- ELSE
- IF type|<>rect|
- ed#=ed#+100 !Take out some perspective effect from the other graphs
- ENDIF
- ENDIF
- DIV m7#,ed#
- DIV m8#,ed#
- DIV m9#,ed#
- m6#=m7#*m7#+m8#*m8#
- IF m6#=0 OR m9#<0
- IF m6#=0
- m4#=0
- m5#=1
- ENDIF
- IF m9#<0
- m4#=m7#
- m5#=m8#
- DIV m6#,-m9#
- ENDIF
- ELSE
- m4#=-m7#
- m5#=-m8#
- DIV m6#,m9#
- ENDIF
- m1#=m5#*m9#-m6#*m8#
- m2#=m6#*m7#-m4#*m9#
- m3#=m4#*m8#-m5#*m7#
- mx#=SQR(m4#*m4#+m5#*m5#+m6#*m6#)
- DIV m4#,mx#
- DIV m5#,mx#
- DIV m6#,mx#
- mx#=SQR(m1#*m1#+m2#*m2#+m3#*m3#)
- DIV m1#,mx#
- DIV m2#,mx#
- DIV m3#,mx#
- RETURN
- PROCEDURE kolorit
- ' CCCCCCCCCCCCCCCCCCCCCC-Color the Graph-CCCCCCCCCCCCCCCCCCCCCCCC
- ADD qz1#,qz2#
- DIV qz1#,2
- colrb%=INT((zhi#-qz1#)/dz1#)
- IF colrb%>13
- colrb%=13
- ENDIF
- IF colrb%<0
- colrb%=0
- ENDIF
- COLOR colrtable|(colrb%+1)
- IF ptrn|=100
- DEFFILL colrtable|(colrb%+1),0,0
- ELSE
- DEFFILL colrtable|(colrb%+1),2,ptrn|
- ENDIF
- RETURN
- PROCEDURE rect
- ' RRRRRRRRRRRRRRR-Compute Rectangular Coordinates-RRRRRRRRRRRRRRR
- funct_error!=FALSE
- ON ERROR GOSUB discont_funct !Trap function errors
- dx#=(maxx#(type|)-minx#(type|))/pntint_x%(type|)
- dy#=(maxy#(type|)-miny#(type|))/pntint_y%(type|)
- x#=minx#(type|)-dx#
- y0#=miny#(type|)-dy#
- firstpass%=1
- i%=0
- REPEAT
- ADD x#,dx#
- y#=y0#
- j%=0
- REPEAT
- ADD y#,dy#
- IF custom_funct!(type|)=TRUE
- var1#=x#
- var2#=y#
- GOSUB evaluate
- z#=stack#(stack_ptr%)
- ELSE
- ON equat%(type|)+1 GOSUB rec0,rec1,rec2,rec3,rec4,rec5,rec6,rec7,rec8,rec9,rec10,rec11,rec12,rec13,rec14,rec15,rec16
- ENDIF
- DEC calc_points%
- PRINT AT(21,4);calc_points%;" "
- IF NOT funct_error!
- px#(i%,j%)=x#
- py#(i%,j%)=y#
- pz#(i%,j%)=z#
- IF z#<max_limit#(type|) AND z#>min_limit#(type|)
- GOSUB hilo
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- INC j%
- funct_error!=FALSE
- UNTIL j%=pntint_y%(type|)+1
- INC i%
- UNTIL i%=pntint_x%(type|)+1
- ON ERROR
- RETURN
- PROCEDURE spheric
- ' SSSSSSSSSSSSSSSSSSSS-Spherical Coordinates-SSSSSSSSSSSSSSSSSSSS
- ' Set initial spherical values
- min_phi#=minx#(type|)
- max_phi#=maxx#(type|)
- min_theta#=miny#(type|)
- max_theta#=maxy#(type|)
- pntint_phi%=pntint_x%(type|)
- pntint_theta%=pntint_y%(type|)
- dphi#=(max_phi#-min_phi#)/pntint_phi%
- dtheta#=(max_theta#-min_theta#)/pntint_theta%
- phi#=min_phi#-dphi#
- theta0#=min_theta#-dtheta#
- firstpass%=1
- ON ERROR GOSUB discont_funct
- i%=0
- ' -- Compute spherical coords & convert to rectangular --
- REPEAT
- ADD phi#,dphi#
- theta#=theta0#
- j%=0
- REPEAT
- ADD theta#,dtheta#
- IF custom_funct!(type|)
- var1#=phi#
- var2#=theta#
- GOSUB evaluate
- IF NOT funct_error!
- r#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB sph0,sph1,sph2,sph3,sph4,sph5,sph6,sph7,sph8,sph9,sph10,sph11,sph12,sph13,sph14,sph15
- ENDIF
- DEC calc_points%
- PRINT AT(21,4);calc_points%;" "
- IF NOT funct_error!
- ' Convert to rectangular values
- px#(i%,j%)=r#*SIN(phi#)*COS(theta#)
- py#(i%,j%)=r#*SIN(phi#)*SIN(theta#)
- pz#(i%,j%)=r#*COS(phi#)
- IF r#<max_limit#(type|) AND r#>min_limit#(type|)
- GOSUB hilo
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- INC j%
- funct_error!=FALSE
- UNTIL j%=pntint_theta%+1
- INC i%
- UNTIL i%=pntint_phi%+1
- ON ERROR
- RETURN
- PROCEDURE cylin
- ' ++++++++++++++++++++Cylindrical Coordinates++++++++++++++++++++
- ' Set initial cylindrical values
- funct_error!=FALSE
- min_theta#=minx#(type|)
- max_theta#=maxx#(type|)
- minz#=miny#(type|)
- maxz#=maxy#(type|)
- pntint_theta%=pntint_x%(type|)
- ' Pntint_theta is the number of theta intervals
- pntint_z%=pntint_y%(type|)
- ON ERROR GOSUB discont_funct
- dtheta#=(max_theta#-min_theta#)/pntint_theta%
- dz#=(maxz#-minz#)/pntint_z%
- z#=minz#-dz#
- z0#=min_z#-dz#
- firstpass%=1
- i%=0
- ' CCCC-Compute Cylindrical coords & convert to rectangular-CCCC
- REPEAT
- ADD theta#,dtheta#
- z#=z0#
- j%=0
- REPEAT
- ADD z#,dz#
- IF custom_funct!(type|)=TRUE
- var1#=z#
- var2#=theta#
- GOSUB evaluate
- IF NOT funct_error!
- r#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB cyl0,cyl1,cyl2,cyl3,cyl4,cyl5,cyl6,cyl7,cyl8,cyl9,cyl10,cyl11,cyl12,cyl13,cyl14,cyl15,cyl16
- ENDIF
- DEC calc_points%
- PRINT AT(21,4);calc_points%;" "
- IF NOT funct_error!
- px#(i%,j%)=r#*COS(theta#)
- py#(i%,j%)=r#*SIN(theta#)
- pz#(i%,j%)=z#
- IF r#<max_limit#(type|) AND r#>min_limit#(type|)
- GOSUB hilo
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- INC j%
- funct_error!=FALSE
- UNTIL j%=pntint_z%+1
- INC i%
- UNTIL i%=pntint_theta%+1
- ON ERROR
- RETURN
- PROCEDURE cart
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~-Cartesian-~~~~~~~~~~~~~~~~~~~~~~~~~~
- ' Plotted on the Z-Y plane..X is plotted on Y axis and Y on the Z axis
- ' Confusing isn't it?!
- ' Set the initial cartesian values
- ON ERROR GOSUB discont_funct
- funct_error!=FALSE
- dx#=(maxx#(type|)-minx#(type|))/pntint_y%(type|)
- x#=minx#(type|)-dx#
- firstpass%=1
- i%=0
- j%=0
- ' Compute Cartesian Points and move to Y-Z plane
- REPEAT
- ADD x#,dx#
- IF custom_funct!(type|)
- var1#=x#
- GOSUB evaluate
- IF NOT funct_error!
- y#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB car0,car1,car2,car3,car4,car5,car6,car7,car8,car9,car10,car11,car12,car13,car14,car15
- ENDIF
- DEC calc_points%
- PRINT AT(21,4);calc_points%;" "
- IF NOT funct_error!
- px#(i%,j%)=0
- py#(i%,j%)=x#
- pz#(i%,j%)=y#
- z#=y#
- IF z#<max_limit#(type|) AND z#>min_limit#(type|)
- GOSUB hilo
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- INC j%
- funct_error!=FALSE
- UNTIL j%=pntint_y%(type|)+1
- ON ERROR
- RETURN
- PROCEDURE polar
- ' PPPPPPPPPPPPPPPPPPPPPPPPPP-Polar-PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
- ' Set initial polar values
- ON ERROR GOSUB discont_funct
- min_theta#=minx#(type|)
- max_theta#=maxx#(type|)
- pntint_theta%=pntint_y%(type|)
- dtheta#=(max_theta#-min_theta#)/pntint_theta%
- theta#=min_theta#-dtheta#
- firstpass%=1
- i%=0
- j%=0
- discont!=FALSE
- ' Compute Polar points and convert to rectangular
- ' Plotted on the Y-Z axis like cartesian
- REPEAT
- ADD theta#,dtheta#
- IF custom_funct!(type|)=TRUE
- var1#=theta#
- GOSUB evaluate
- IF NOT funct_error!
- r#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB pol0,pol1,pol2,pol3,pol4,pol5,pol6,pol7,pol8,pol9,pol10,pol11,pol12,pol13,pol14,pol15
- ENDIF
- DEC calc_points%
- PRINT AT(21,4);calc_points%;" "
- IF NOT funct_error!
- y#=r#*SIN(theta#)
- z#=r#*COS(theta#)
- px#(i%,j%)=0
- py#(i%,j%)=z# !Turn it sideways to be conventional
- pz#(i%,j%)=y#
- IF r#<max_limit#(type|) AND r#>min_limit#(type|)
- IF discont!=TRUE !If we moved from discontinuous to continuous area
- GOSUB fnd_cont_pnt(theta#,dtheta#)
- ENDIF
- GOSUB hilo
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- discont!=FALSE
- ELSE
- IF j%<>0 AND discont!=FALSE !If we moved from continuous to discontinuous
- ' and it is not the first point
- GOSUB fnd_cont_pnt(theta#,dtheta#)
- IF r#<max_limit#(type|) AND r#>min_limit#(type|)
- GOSUB hilo
- ENDIF
- ELSE
- pz#(i%,j%)=funct_error%
- ENDIF
- IF funct_error!=TRUE
- discont!=TRUE
- ENDIF
- ENDIF
- INC j%
- funct_error!=FALSE
- UNTIL j%=pntint_theta%+1
- ON ERROR
- RETURN
- PROCEDURE xaxis
- ' XXXXXXXXXXXXXXXXXXX-Perpendicular to x-axis-XXXXXXXXXXXXXXXXXXX
- COLOR 1
- FOR i%=0 TO pntint_x%(type|) STEP lintx%(type|)
- FOR j%=0 TO pntint_y%(type|)
- qx#=px#(i%,j%)
- qy#=py#(i%,j%)
- qz#=pz#(i%,j%)
- IF pz#(i%,j%)<>funct_error%
- GOSUB calcsxsy
- IF j%=0 OR funct_error!
- x%(0)=sx#
- y%(0)=sy#
- qz1#=pz#(i%,j%)
- funct_error!=FALSE
- ELSE
- x%(1)=sx#
- y%(1)=sy#
- qz2#=pz#(i%,j%)
- IF kolor!
- GOSUB kolorit
- ENDIF
- POLYLINE 2,x%(),y%()
- x%(0)=sx#
- y%(0)=sy#
- qz1#=qz2#
- ENDIF
- ELSE
- funct_error!=TRUE
- ENDIF
- NEXT j%
- NEXT i%
- RETURN
- PROCEDURE yaxis
- ' YYYYYYYYYYYYYYYYYYY-Perpendicular to y-axis-YYYYYYYYYYYYYYYYYYY
- COLOR 1
- FOR j%=0 TO pntint_y%(type|) STEP linty%(type|)
- FOR i%=o# TO pntint_x%(type|)
- qx#=px#(i%,j%)
- qy#=py#(i%,j%)
- qz#=pz#(i%,j%)
- IF pz#(i%,j%)<>funct_error%
- GOSUB calcsxsy
- IF i%=0 OR funct_error!
- x%(0)=sx#
- y%(0)=sy#
- qz1#=pz#(i%,j%)
- funct_error!=FALSE
- ELSE
- x%(1)=sx#
- y%(1)=sy#
- qz2#=pz#(i%,j%)
- IF kolor!
- GOSUB kolorit
- ENDIF
- POLYLINE 2,x%(),y%()
- x%(0)=sx#
- y%(0)=sy#
- qz1#=qz2#
- ENDIF
- ELSE
- funct_error!=TRUE
- ENDIF
- NEXT i%
- NEXT j%
- RETURN
- PROCEDURE hidden_lines
- ' XXXXXXXXXXXXXXXXXXX-Hidden line routine-XXXXXXXXXXXXXXXXXXX
- COLOR 1
- IF ptrn|=100
- DEFFILL 1,0,0
- ELSE
- DEFFILL 1,2,ptrn|
- ENDIF
- n%=0
- REPEAT
- qz1#=zlo# !initial values for color bands
- qz2#=zhi#
- funct_error!=FALSE
- i%=pnt_no%(n%)/pntint_y%(type|)
- j%=pnt_no%(n%) MOD pntint_y%(type|)
- k%=0
- x%=i%
- y%=j%
- GOSUB x_y_arrayfill
- INC x%
- INC k%
- GOSUB x_y_arrayfill
- INC y%
- INC k%
- GOSUB x_y_arrayfill
- DEC x%
- INC k%
- GOSUB x_y_arrayfill
- x%(4)=x%(0)
- y%(4)=y%(0)
- IF NOT funct_error!
- IF kolor!
- GOSUB kolorit
- ENDIF
- POLYFILL 5,x%(),y%()
- IF ptrn|>2 AND ptrn|<9
- COLOR colrtable|(15)
- IF ptrn|=8
- COLOR colrtable|(0)
- ENDIF
- ENDIF
- POLYLINE 5,x%(),y%()
- ENDIF
- INC n%
- UNTIL n%=no_pnts%
- RETURN
- PROCEDURE x_y_arrayfill
- ' ---------- Fill the array for polyfill ------------
- qx#=px#(x%,y%)
- qy#=py#(x%,y%)
- qz#=pz#(x%,y%)
- IF qz#<>funct_error%
- IF kolor!
- qz1#=MAX(qz#,qz1#)
- qz2#=MIN(qz#,qz2#)
- ENDIF
- GOSUB calcsxsy
- x%(k%)=sx#
- y%(k%)=sy#
- ELSE
- funct_error!=TRUE
- ENDIF
- RETURN
- PROCEDURE eye_dist
- ' ------------ calculate the eye distances -------------
- i%=0
- REPEAT
- j%=0
- REPEAT
- IF pz#(i%,j%)<>funct_error%
- edx#=ABS(ex%(type|)-px#(i%,j%))
- edy#=ABS(ey%(type|)-py#(i%,j%))
- edz#=ABS(ez%(type|)-pz#(i%,j%))
- ed_sur0#=edx#+edy#+edz#
- edx1#=ABS(ex%(type|)-px#(i%+1,j%+1))
- edy1#=ABS(ey%(type|)-py#(i%+1,j%+1))
- edz1#=ABS(ez%(type|)-pz#(i%+1,j%+1))
- ed_sur1#=edx1#+edy1#+edz1#
- ed_surface#(i%*pntint_y%(type|)+j%)=(ed_sur0#+ed_sur1#)/2
- ELSE
- ed_surface#(i%*pntint_y%(type|)+j%)=funct_error%
- ENDIF
- INC j%
- UNTIL j%=pntint_y%(type|)
- INC i%
- UNTIL i%=pntint_x%(type|)
- RETURN
- PROCEDURE quick_sort
- ' ---------------- Sort the eye distances --------------
- no_pnts%=pntint_x%(type|)*pntint_y%(type|)
- ' Fill the pnt_no%() array
- i%=0
- REPEAT
- pnt_no%(i%)=i%
- INC i%
- UNTIL i%=no_pnts%+1
- GOSUB quicksort(*ed_surface#(),0,no_pnts%-1)
- RETURN
- PROCEDURE quicksort(str.arr%,l%,r%)
- LOCAL x#
- SWAP *str.arr%,ed_surface#()
- @quick(l%,r%)
- SWAP *str.arr%,ed_surface#()
- RETURN
- PROCEDURE quick(l%,r%)
- LOCAL ll%,rr%
- ll%=l%
- rr%=r%
- x#=ed_surface#((l%+r%)/2)
- REPEAT
- WHILE ed_surface#(l%)>x#
- INC l%
- WEND
- WHILE ed_surface#(r%)<x#
- DEC r%
- WEND
- IF l%<=r%
- SWAP ed_surface#(l%),ed_surface#(r%)
- SWAP pnt_no%(l%),pnt_no%(r%)
- INC l%
- DEC r%
- ENDIF
- UNTIL l%>r%
- IF ll%<r%
- @quick(ll%,r%)
- ENDIF
- IF l%<rr%
- @quick(l%,rr%)
- ENDIF
- RETURN
- PROCEDURE hilo
- ' hhhhhhhhhhhhhhhhhhhhhhhhhh-Find hi/lo-hhhhhhhhhhhhhhhhhhhhhhhhh
- ' Find high and low values in each direction
- IF firstpass%=1
- zlo#=pz#(i%,j%)
- zhi#=pz#(i%,j%)
- xhi#=px#(i%,j%)
- xlo#=px#(i%,j%)
- yhi#=py#(i%,j%)
- ylo#=py#(i%,j%)
- firstpass%=2
- ELSE
- IF pz#(i%,j%)>zhi#
- zhi#=pz#(i%,j%)
- izhi%=i%
- jzhi%=j%
- ENDIF
- xhi#=MAX(px#(i%,j%),xhi#)
- yhi#=MAX(py#(i%,j%),yhi#)
- zlo#=MIN(pz#(i%,j%),zlo#)
- xlo#=MIN(px#(i%,j%),xlo#)
- ylo#=MIN(py#(i%,j%),ylo#)
- ENDIF
- RETURN
- PROCEDURE drwaxes
- ' dddddddddddddddddddddddddd-Draw Axes-dddddddddddddddddddddddddd
- xahi#=MAX(ABS(xhi#),ABS(xlo#))
- yahi#=MAX(ABS(yhi#),ABS(ylo#))
- zahi#=MAX(ABS(zhi#),ABS(zlo#))
- qahi#=MAX(xahi#,yahi#,zahi#)
- qx#=0
- qy#=0
- qz#=0
- GOSUB calcsxsy
- originx#=sx#
- originy#=sy#
- IF res|=med|
- COLOR 3
- ELSE
- COLOR 1
- ENDIF
- qx#=0
- qy#=0
- qz#=zahi#+0.3*qahi#
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- IF three_d!
- TEXT sx#+2,sy#-2,"z"
- ELSE
- TEXT sx#+2,sy#-2,"y"
- ENDIF
- qx#=0
- qy#=yahi#+0.3*qahi#
- qz#=0
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- IF three_d!
- TEXT sx#+2,sy#-2,"y"
- ELSE
- TEXT sx#+2,sy#-2,"x"
- ENDIF
- IF three_d!
- qx#=xahi#+0.3*qahi#
- qy#=0
- qz#=0
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- TEXT sx#+2,sy#-2,"x"
- ENDIF
- DEFLINE 2,1,0,0
- qx#=0
- qy#=0
- qz#=-zahi#-0.3*qahi#
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- qx#=0
- qy#=-yahi#-0.3*qahi#
- qz#=0
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- IF three_d!
- qx#=-xahi#-0.3*qahi#
- qy#=0
- qz#=0
- GOSUB calcsxsy
- DRAW originx#,originy# TO sx#,sy#
- ENDIF
- DEFLINE 1,1,0,0
- RETURN
- PROCEDURE screenswap
- ' ________Swap the screens________
- IF scrn|=0 !If we are on the menu screen
- IF res|<>hi|
- SETCOLOR 1,sav_colr%(0)
- SETCOLOR 2,sav_colr%(1)
- ENDIF
- MENU KILL
- MENU OFF
- SPUT screen1$ !Return the graph screen
- scrn|=1
- GOSUB hide_mouse
- ELSE
- scrn|=0
- CLS
- FOR i%=1 TO 2
- GOSUB get_color
- sav_colr%(i%-1)=hue%
- NEXT i%
- GOSUB param_menu !Reprint the menu screen
- PAUSE 30
- ENDIF
- RETURN
- PROCEDURE open_file
- ' ooooooooooooooooooooooooooo-Open file-ooooooooooooooooooooooooo
- ON ERROR GOSUB disk_err
- drive$=CHR$(GEMDOS(25)+65)
- filename$=""
- IF DIR$(0)<>""
- graphfil$=drive$+":"+DIR$(0)+"\*"+extender$
- ELSE
- graphfil$=drive$+":\*"+extender$
- ENDIF
- select:
- FILESELECT graphfil$,"",filename$
- IF filename$<>""
- IF filename$<>drive$+":" AND RIGHT$(filename$)<>"\"
- period%=INSTR(filename$,".")
- IF period%=0
- filename$=filename$+extender$
- ELSE
- IF choice|<>5
- filename$=LEFT$(filename$,period%-1)+extender$
- ENDIF
- ENDIF
- backslash%=-1
- REPEAT
- dum%=backslash%
- INC dum%
- backslash%=INSTR(dum%,filename$,"\")
- UNTIL backslash%=0
- CHDRIVE ASC(LEFT$(filename$))-64
- path$=MID$(filename$,INSTR(filename$,"\"),dum%-INSTR(filename$,"\")-1)
- IF path$<>""
- CHDIR path$
- ELSE
- CHDIR "\"
- ENDIF
- DEFMOUSE 2
- IF choice|<>5
- OPEN "O",#1,filename$
- ON choice| GOSUB degas_save,neo_save,param_save,cad3d_save
- ELSE
- IF EXIST(filename$)
- GOSUB get_graph_file
- ELSE
- ALERT 1,"|File not found",1,"OK",dum%
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- abort_open:
- CLOSE #1
- DEFMOUSE 0
- ON ERROR
- RETURN
- PROCEDURE degas_save
- ' ssssssssssssssssssssssssss-Degas Save-sssssssssssssssssssssssss
- ' --- DEGAS file write ---
- degasheader$=MKI$(res|)
- FOR i%=0 TO 15
- IF i%<>1 AND i%<>2
- GOSUB get_color
- ELSE
- hue%=sav_colr%(i%-1)
- ENDIF
- degasheader$=degasheader$+MKI$(hue%)
- NEXT i%
- BPUT #1,VARPTR(degasheader$),34
- BPUT #1,VARPTR(screen1$),32000
- RETURN
- PROCEDURE neo_save
- ' nnnnnnnnnnnnnnnnnnnnnnnnnnn-NEO Save-nnnnnnnnnnnnnnnnnnnnnnnnnn
- ' -------- Neo Write ----------
- temp$=""
- temp$=temp$+MKL$(0)
- FOR i%=0 TO 15
- IF i%<>1 AND i%<>2
- GOSUB get_color
- ELSE
- hue%=sav_colr%(i%-1)
- ENDIF
- temp$=temp$+MKI$(hue%)
- NEXT i%
- FOR i%=1 TO 6
- temp$=temp$+MKI$(0)
- NEXT i%
- temp$=temp$+MKI$(&H801F)
- FOR i%=1 TO 39
- temp$=temp$+MKI$(0)
- NEXT i%
- BPUT #1,VARPTR(temp$),128
- BPUT #1,VARPTR(screen1$),32000
- RETURN
- PROCEDURE get_color
- ' ----- Get colors -----
- DPOKE CONTRL,26
- DPOKE CONTRL+2,0
- DPOKE CONTRL+6,2
- DPOKE INTIN,colrtable|(i%)
- DPOKE INTIN+2,1
- VDISYS
- rgb%(0)=DPEEK(INTOUT+2)
- rgb%(1)=DPEEK(INTOUT+4)
- rgb%(2)=DPEEK(INTOUT+6)
- FOR j%=0 TO 2
- rgb%(j%)=INT(rgb%(j%)/142)
- NEXT j%
- hue%=rgb%(0)*&H100+rgb%(1)*&H10+rgb%(2)
- RETURN
- PROCEDURE disk_err
- ' ----- Disk error procedure -----
- DEFMOUSE 0
- ' If the disk was write protected GEM already gave them an alert box so skip this one
- IF ERR<>-13
- ALERT 3," Disk Error. | Operation Aborted. ",1,"Ok",dum%
- title!=TRUE
- CLS
- GOSUB param_menu
- ENDIF
- RESUME abort_open
- RETURN
- PROCEDURE param_save
- ' ggggggggggggggggggggggggg-Graph Save-gggggggggggggggggggggggggg
- ' --- Graph file write ---
- WRITE #1,p_file$
- WRITE #1,type|,custom_funct!(type|),cfunctlabel$(type|),equat%(type|),z%(type|),ex%(type|),ey%(type|),ez%(type|),cx%(type|),cy%(type|),minx#(type|),maxx#(type|)
- WRITE #1,miny#(type|),maxy#(type|),min_limit#(type|),max_limit#(type|),pntint_x%(type|),pntint_y%(type|),lintx%(type|),linty%(type|)
- FOR i%=1 TO 10
- WRITE #1,const#(type|,i%)
- NEXT i%
- RETURN
- PROCEDURE get_graph_file
- ' RRRRRRRRRRRRRRRRRRRRRRR-Read in a Graph-RRRRRRRRRRRRRRRRRRRRRRRR
- OPEN "I",#1,filename$
- INPUT #1,version$
- IF p_file$<>"PM-1.00"
- ALERT 3," |Error: Not a Parameters File.",1,"Ok",dum%
- ELSE
- INPUT #1,type|,custom_funct!(type|),cfunctlabel$(type|),equat%(type|),z%(type|),ex%(type|),ey%(type|),ez%(type|),cx%(type|),cy%(type|),minx#(type|),maxx#(type|)
- INPUT #1,miny#(type|),maxy#(type|),min_limit#(type|),max_limit#(type|),pntint_x%(type|),pntint_y%(type|),lintx%(type|),linty%(type|)
- IF pntint_x%(type|)>max_pts|
- pntint_x%(type|)=max_pts|
- ENDIF
- IF pntint_y%(type|)>max_pts|
- pntint_y%(type|)=max_pts|
- ENDIF
- FOR i%=1 TO 10
- INPUT #1,const#(type|,i%)
- NEXT i%
- ENDIF
- RETURN
- PROCEDURE param_menu
- ' mmmmmmmmmmmmmmmmmmmmmmm-Parameter Menu-mmmmmmmmmmmmmmmmmmmmmmmm
- ' Print the Main Menu screen
- SETCOLOR 1,0,0,6
- SETCOLOR 2,0,7,1
- DEFFILL colrtable|(0),2,8
- PBOX 33*rxf|,42*ryf|,309*rxf|,157*ryf|
- IF title!=TRUE !Do we need to redraw the box and title
- SPUT mscreen$
- ENDIF
- DEFTEXT 1,0,0,rtxt1|
- COLOR colrtable|(15)
- GOSUB funct_title
- GOSUB equation
- GOSUB zoom
- GOSUB eye
- GOSUB scrn_center
- GOSUB param1
- GOSUB param2
- GOSUB param3
- GOSUB pint
- GOSUB lint
- MENU d$()
- GOSUB mark_menu
- ON MENU GOSUB set_options
- RETURN
- PROCEDURE funct_title
- TEXT 20*rxf|,40*ryf|,SPACE$(sclear|)
- ' Text 20*Rxf%,43*Ryf%,Space$(Sclear%)
- type1$=type$(type|)+" Coordinates Parameters"
- TEXT 20*rxf|,43*ryf|,LEFT$("__________________________________",LEN(type1$))
- TEXT 20*rxf|,40*ryf|,type1$
- RETURN
- PROCEDURE equation
- TEXT 41*rxf|,53*ryf|,"Function:"
- GOSUB prntfunct
- IF res|=lo|
- DEFTEXT 1,0,0,4
- ENDIF
- IF custom_funct!(type|)=TRUE
- IF type|=rect|
- temp$="z="
- ELSE
- IF type|=cart|
- temp$="y="
- ELSE
- temp$="r="
- ENDIF
- ENDIF
- temp$=temp$+cfunctlabel$(type|)
- ELSE
- temp$=functlabel$
- ENDIF
- IF res|=lo| AND LEN(temp$)>44
- temp1$=LEFT$(temp$,31)
- TEXT 115*rxf|,53*ryf|,temp1$
- temp$=MID$(temp$,32)
- ENDIF
- TEXT 41*rxf|,61*ryf|,temp$
- DEFTEXT 1,0,0,rtxt1|
- RETURN
- PROCEDURE zoom
- ' Text 33*Rxf%,71*Ryf%,Space$(Sclear%)
- temp$="Zoom Factor="+STR$(INT(z%(type|)))
- TEXT 41*rxf|,71*ryf|,temp$
- RETURN
- PROCEDURE eye
- IF NOT three_d!
- temp$="Not Applicable"
- ELSE
- temp$="Ex="+STR$(ex%(type|))+" Ey="+STR$(ey%(type|))+" Ez="+STR$(ez%(type|))+" "
- ENDIF
- ' Text 33*Rxf%,90*Ryf%,Space$(Sclear%)
- TEXT 41*rxf|,81*ryf|,"Eye Position:"
- TEXT 40*rxf|,90*ryf|,temp$
- RETURN
- PROCEDURE scrn_center
- ' Text 33*Rxf%,99*Ryf%,Space$(Sclear%)
- temp$="Screen Center: Cx="+STR$(cx%(type|))+" Cy="+STR$(cy%(type|))
- TEXT 41*rxf|,99*ryf|,temp$
- RETURN
- PROCEDURE param1
- ' Text 33*Rxf%,109*Ryf%,Space$(Sclear%)
- IF type|=sphere| OR type|=polar| OR type|=cylin|
- temp$=paramx$(type|)+" Range: "+paramx$(type|)+"low="+STR$(INT(minx#(type|)*180/PI+0.01))+"° "+paramx$(type|)+"hi="+STR$(INT(maxx#(type|)*180/PI+0.01))+"°"
- ELSE
- temp$=paramx$(type|)+" Range: "+paramx$(type|)+"low="+STR$(minx#(type|))+" "+paramx$(type|)+"hi="+STR$(maxx#(type|))
- ENDIF
- TEXT 41*rxf|,109*ryf|,temp$
- RETURN
- PROCEDURE param2
- ' Text 33*Rxf%,119*Ryf%,Space$(Sclear%)
- IF type|=sphere|
- temp$=paramy$(type|)+" Range: "+paramy$(type|)+"low="+STR$(INT(miny#(type|)*180/PI+0.01))+"° "+paramy$(type|)+"hi="+STR$(INT(maxy#(type|)*180/PI+0.01))+"°"
- ENDIF
- IF type|=rect| OR type|=cylin|
- temp$=paramy$(type|)+" Range: "+paramy$(type|)+"low="+STR$(miny#(type|))+" "+paramy$(type|)+"hi="+STR$(maxy#(type|))
- ENDIF
- IF NOT three_d!
- temp$=paramy$(type|)+" Range: "+paramy$(type|)+"low="+STR$(min_limit#(type|))+" "+paramy$(type|)+"hi="+STR$(max_limit#(type|))
- ENDIF
- TEXT 41*rxf|,119*ryf|,temp$
- RETURN
- PROCEDURE param3
- ' Text 33*Rxf%,129*Ryf%,Space$(Sclear%)
- IF NOT three_d!
- temp$="Z Range: Not Applicable"
- ELSE
- temp$=paramz$(type|)+" Range: "+paramz$(type|)+"low="+STR$(min_limit#(type|))+" "+paramz$(type|)+"hi="+STR$(max_limit#(type|))
- ENDIF
- TEXT 41*rxf|,129*ryf|,temp$
- RETURN
- PROCEDURE pint
- ' Text 33*Rxf%,139*Ryf%,Space$(Sclear%)
- temp$="Point Intervals: "
- IF NOT three_d!
- temp$=temp$+"P"+paramx$(type|)+"="+STR$(pntint_y%(type|))
- ELSE
- temp$=temp$+"P"+paramx$(type|)+"="+STR$(pntint_x%(type|))+" P"+paramy$(type|)+"="+STR$(pntint_y%(type|))
- ENDIF
- TEXT 41*rxf|,139*ryf|,temp$
- RETURN
- PROCEDURE lint
- TEXT 33*rxf|,149*ryf|,SPACE$(sclear|)
- temp$="Line Intervals: "
- IF NOT three_d!
- IF x_int#==PI/4
- temp$="Grid Intervals: X=Trig Y="+LEFT$(STR$(y_int#),5)
- ELSE
- temp$="Grid Intervals: X="+STR$(x_int#)+" Y="+STR$(y_int#)
- ENDIF
- ELSE
- IF hide_lines|=on|
- temp$=temp$+"Not Applicable"
- ELSE
- temp$=temp$+"L"+paramx$(type|)+"="+STR$(lintx%(type|))+" L"+paramy$(type|)+"="+STR$(linty%(type|))
- ENDIF
- ENDIF
- TEXT 41*rxf|,149*ryf|,temp$
- RETURN
- PROCEDURE chg_params
- ' PPPPPPPPPPPPPPPPPPPPPP-Change Parameters-PPPPPPPPPPPPPPPPPPPPPP
- MOUSE micex&,micey&,dum%
- ' Mice!???
- IF micex&>20*rxf| AND micex&<33*rxf|
- IF micey&>45*ryf| AND micey&<54*ryf|
- GOSUB nwfunction
- GOSUB param_menu
- ENDIF
- IF micey&>63*ryf| AND micey&<72*ryf|
- a_scl|=off|
- GOSUB mark_menu
- PRINT AT(6,22);"Zoom=";
- FORM INPUT 4,temp$
- GOSUB clearit_all
- z%(type|)=ABS(INT(VAL(temp$)))
- IF z%(type|)=0
- z%(type|)=1
- ENDIF
- TEXT 33*rxf|,71*ryf|,SPACE$(sclear|)
- GOSUB zoom
- ENDIF
- IF micey&>73*ryf| AND micey&<82*ryf|
- IF three_d!
- PRINT AT(6,22);"Eye Position: Ex, Ey and Ez"
- PRINT AT(6,23);"Ex=";
- FORM INPUT 3,temp$
- ex%(type|)=INT(VAL(temp$))
- GOSUB clearit
- PRINT AT(6,23);"Ey=";
- FORM INPUT 3,temp$
- ey%(type|)=INT(VAL(temp$))
- GOSUB clearit
- PRINT AT(6,23);"Ez=";
- FORM INPUT 3,temp$
- ez%(type|)=INT(VAL(temp$))
- GOSUB clearit_all
- IF graph!<>FALSE
- GOSUB form_matrix
- ENDIF
- TEXT 33*rxf|,90*ryf|,SPACE$(sclear|)
- GOSUB eye
- ENDIF
- ENDIF
- IF micey&>91*ryf| AND micey&<100*ryf|
- a_ctr|=off|
- GOSUB mark_menu
- PRINT AT(6,22);"Center of Screen: Cx,Cy"
- PRINT AT(6,23);"Cx=";
- FORM INPUT 4,temp$
- cx%(type|)=INT(VAL(temp$))
- GOSUB clearit
- PRINT AT(6,23);"Cy=";
- FORM INPUT 4,temp$
- cy%(type|)=INT(VAL(temp$))
- GOSUB clearit_all
- TEXT 33*rxf|,99*ryf|,SPACE$(sclear|)
- GOSUB scrn_center
- ENDIF
- IF micey&>101*ryf| AND micey&<110*ryf|
- tryagain_x:
- PRINT AT(6,22);paramx$(type|)+" Values: "+paramx$(type|)+"lo,"+paramx$(type|)+"hi";
- PRINT AT(6,23);paramx$(type|)+"lo=";
- FORM INPUT 5,temp$
- GOSUB clearit
- GOSUB dec_val
- IF type|=rect| OR type|=cart|
- minx#(type|)=d_val#
- ELSE
- minx#(type|)=VAL(temp$)*PI/180
- ENDIF
- PRINT AT(6,23);paramx$(type|)+"hi=";
- FORM INPUT 5,temp$
- GOSUB clearit_all
- IF temp$<>""
- GOSUB dec_val
- IF type|=rect| OR type|=cart|
- maxx#(type|)=d_val#
- ELSE
- maxx#(type|)=VAL(temp$)*PI/180
- ENDIF
- ELSE
- maxx#(type|)=ABS(minx#(type|))
- ENDIF
- IF minx#(type|)>=maxx#(type|)
- GOSUB inp_error
- GOTO tryagain_x
- ENDIF
- cf!=TRUE
- TEXT 33*rxf|,109*ryf|,SPACE$(sclear|)
- GOSUB param1
- ENDIF
- IF micey&>111*ryf| AND micey&<120*ryf|
- tryagain_y:
- PRINT AT(6,22);paramy$(type|)+" Values: "+paramy$(type|)+"lo,"+paramy$(type|)+"hi";
- PRINT AT(6,23);paramy$(type|)+"lo=";
- FORM INPUT 5,temp$
- GOSUB clearit
- GOSUB dec_val
- IF type|=sphere|
- miny#(type|)=VAL(temp$)*PI/180
- ELSE
- IF NOT three_d!
- min_limit#(type|)=d_val#
- ELSE
- miny#(type|)=d_val#
- ENDIF
- ENDIF
- PRINT AT(6,23);paramy$(type|)+"hi=";
- FORM INPUT 5,temp$
- GOSUB clearit_all
- IF temp$<>""
- GOSUB dec_val
- IF type|=sphere|
- maxy#(type|)=VAL(temp$)*PI/180
- ELSE
- IF NOT three_d!
- max_limit#(type|)=d_val#
- ELSE
- maxy#(type|)=d_val#
- ENDIF
- ENDIF
- ELSE
- IF three_d!
- maxy#(type|)=ABS(miny#(type|))
- ELSE
- IF NOT three_d!
- max_limit#(type|)=ABS(min_limit#(type|))
- ENDIF
- ENDIF
- ENDIF
- IF three_d!
- IF miny#(type|)>=maxy#(type|)
- GOSUB inp_error
- GOTO tryagain_y
- ENDIF
- ELSE
- IF min_limit#(type|)>=max_limit#(type|)
- GOSUB inp_error
- GOTO tryagain_y
- ENDIF
- ENDIF
- cf!=TRUE
- TEXT 33*rxf|,119*ryf|,SPACE$(sclear|)
- GOSUB param2
- ENDIF
- IF micey&>121*ryf| AND micey&<130*ryf| AND type|<4
- tryagain_z:
- PRINT AT(6,22);paramz$(type|)+" Values: "+paramz$(type|)+"lo,"+paramz$(type|)+"hi";
- PRINT AT(6,23);paramz$(type|)+"lo=";
- FORM INPUT 5,temp$
- GOSUB clearit
- GOSUB dec_val
- min_limit#(type|)=d_val#
- PRINT AT(6,23);paramz$(type|)+"hi=";
- FORM INPUT 5,temp$
- GOSUB clearit_all
- IF temp$<>""
- GOSUB dec_val
- max_limit#(type|)=d_val#
- IF min_limit#(type|)>=max_limit#(type|)
- GOSUB inp_error
- GOTO tryagain_z
- ENDIF
- ELSE
- max_limit#(type|)=ABS(min_limit#(type|))
- ENDIF
- cf!=TRUE
- TEXT 33*rxf|,129*ryf|,SPACE$(sclear|)
- GOSUB param3
- ENDIF
- IF micey&>131*ryf| AND micey&<140*ryf|
- IF three_d!
- PRINT AT(6,22);"Point Intervals: P"+paramx$(type|)+",P"+paramy$(type|)
- PRINT AT(6,23);"P"+paramx$(type|)+"=";
- FORM INPUT 2,temp$
- pntint_x%(type|)=ABS(INT(VAL(temp$)))
- IF pntint_x%(type|)>max_pts|
- pntint_x%(type|)=max_pts|
- ENDIF
- IF pntint_x%(type|)=0
- pntint_x%(type|)=1
- ENDIF
- GOSUB clearit
- ENDIF
- IF three_d!
- PRINT AT(6,23);"P"+paramy$(type|)+"=";
- FORM INPUT 2,temp$
- ELSE
- PRINT AT(6,23);"P"+paramx$(type|)+"=";
- FORM INPUT 3,temp$
- ENDIF
- IF three_d! AND temp$=""
- pntint_y%(type|)=pntint_x%(type|)
- ELSE
- pntint_y%(type|)=ABS(INT(VAL(temp$)))
- ENDIF
- IF pntint_y%(type|)>max_pts| AND three_d!
- pntint_y%(type|)=max_pts|
- ENDIF
- IF pntint_y%(type|)=0
- pntint_y%(type|)=1
- ENDIF
- cf!=TRUE
- GOSUB clearit_all
- TEXT 33*rxf|,139*ryf|,SPACE$(sclear|)
- GOSUB pint
- ENDIF
- IF micey&>141*ryf| AND micey&<150*ryf|
- IF three_d! AND hide_lines|=off|
- tryagain_lint:
- PRINT AT(6,22);"Line Intervals: L"+paramx$(type|)+",L"+paramy$(type|)
- PRINT AT(6,23);"L"+paramx$(type|)+"=";
- FORM INPUT 2,temp$
- lintx%(type|)=ABS(INT(VAL(temp$)))
- GOSUB clearit
- PRINT AT(6,23);"L"+paramy$(type|)+"=";
- FORM INPUT 2,temp$
- linty%(type|)=ABS(INT(VAL(temp$)))
- GOSUB clearit_all
- ' Text 33*Rxf%,149*Ryf%,Space$(Sclear%)
- GOSUB lint
- IF lintx%(type|)>=pntint_x%(type|)/2 OR linty%(type|)>=pntint_y%(type|)/2
- PRINT AT(6,22);"◆Line Intervals must be less than"
- PRINT AT(6,23);"Points/2"
- PAUSE 150
- GOSUB clearit_all
- GOTO tryagain_lint
- ENDIF
- IF lintx%(type|)>5 OR linty%(type|)>5
- PRINT AT(5,23);"◆Line intervals must be less than 5"
- PAUSE 150
- GOSUB clearit_all
- GOTO tryagain_lint
- ENDIF
- IF lintx%(type|)=0 AND linty%(type|)=0
- PRINT AT(6,23);"◆Both Intervals may not be 0"
- PAUSE 150
- GOSUB clearit_all
- GOTO tryagain_lint
- ENDIF
- ELSE
- IF NOT three_d!
- PRINT AT(6,22);"Grid Intervals X axis, Y axis";
- PRINT AT(6,23);"X Axis=";
- FORM INPUT 5,temp$
- GOSUB clearit
- temp$=UPPER$(temp$)
- IF temp$="PI"
- x_int#=PI/4
- trig!=TRUE
- ELSE
- trig!=FALSE
- GOSUB dec_val
- IF d_val#<0.01
- d_val#=0.5
- ENDIF
- x_int#=d_val#
- ENDIF
- PRINT AT(6,23);"Y Axis=";
- FORM INPUT 5,temp$
- GOSUB clearit_all
- IF temp$<>""
- GOSUB dec_val
- IF d_val#<0.01
- d_val#=0.5
- ENDIF
- y_int#=d_val#
- ELSE
- y_int#=x_int#
- ENDIF
- ' Text 33*Rxf%,149*Ryf%,Space$(Sclear%)
- GOSUB lint
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- RETURN
- PROCEDURE inp_error
- ' ----Input Error-------
- ' Most input errors are handled by the program but we make you redo these
- PRINT "◆";
- PRINT AT(6,22);"Hi value must be greater than lo"
- PAUSE 150
- GOSUB clearit_all
- RETURN
- PROCEDURE clearit
- ' Clear out the line
- PRINT AT(5,23);SPACE$(30)
- RETURN
- PROCEDURE clearit_all
- PRINT AT(5,22);SPACE$(sclear|)
- PRINT AT(5,23);SPACE$(sclear|)
- RETURN
- PROCEDURE dec_val
- ' dddddddddddddddddddddd-Input Decimal Values-ddddddddddddddddddd
- ' Convert the input string to a decimal value
- dcml#=INSTR(temp$,".",0)
- IF dcml#<>0
- d_digits#=LEN(temp$)-dcml#
- d_val#=ABS(VAL(LEFT$(temp$,dcml#-1)))+VAL(MID$(temp$,dcml#+1,d_digits#))/(10^d_digits#)
- IF VAL(temp$)<0
- d_val#=-d_val#
- ENDIF
- ELSE
- d_val#=VAL(temp$)
- ENDIF
- RETURN
- PROCEDURE nwfunction
- ' NNNNNNNNNNNNNNNNNNNNNNNNN- New Function-NNNNNNNNNNNNNNNNNNNNNNN
- HIDEM
- cf!=TRUE
- CLS
- PRINT ''"<Esc> to abort (before selecting)"
- PRINT ''"<F1> to enter your own function"
- i%=0
- PRINT
- REPEAT
- PRINT "(";CHR$(65+i%);") ";
- IF res|<>lo|
- PRINT function$(type|,i%)
- ELSE
- PRINT LEFT$(function$(type|,i%),34)
- IF LEN(function$(type|,i%))>34
- PRINT SPACE$(6);MID$(function$(type|,i%),35,LEN(function$(type|,i%)))
- ENDIF
- ENDIF
- INC i%
- UNTIL function$(type|,i%)=""
- maxequa%=i%
- reinput:
- temp%=INP(2)
- temp%=ASC(UPPER$(CHR$(temp%)))
- IF temp%<>27 AND temp%<>187
- SUB temp%,65
- IF temp%>=0 AND temp%<=maxequa%
- equat%(type|)=temp%
- GOSUB constinpt
- GOSUB getconst
- ELSE
- GOTO reinput
- ENDIF
- ENDIF
- IF temp%=187
- custom_funct!(type|)=TRUE
- ELSE
- custom_funct!(type|)=FALSE
- ENDIF
- IF custom_funct!(type|)=TRUE
- CLS
- try_cf_again:
- GOSUB custom_funct
- IF cfunctlabel$(type|)=""
- custom_funct!(type|)=FALSE
- CLS
- GOTO escape
- ENDIF
- GOSUB convert
- IF syntax_error!=TRUE
- GOTO try_cf_again
- ENDIF
- CLS
- escape:
- ENDIF
- CLS
- SHOWM
- RETURN
- PROCEDURE constinpt
- n%(0)=0
- i%=1
- PRINT ''CHR$(10);
- IF res|<>lo|
- PRINT function$(type|,equat%(type|))
- ELSE
- PRINT LEFT$(function$(type|,equat%(type|)),34)
- IF LEN(function$(type|,equat%(type|)))>34
- PRINT SPACE$(4);MID$(function$(type|,equat%(type|)),35,LEN(function$(type|,equat%(type|))))
- ENDIF
- ENDIF
- GOSUB findn
- i_line%=CRSLIN+1
- REPEAT
- PRINT AT(2,i_line%);CHR$(64+i%);"=";
- FORM INPUT 4,temp$
- IF i%=1 AND temp$=""
- FOR k%=1 TO 5
- FOR j%=1 TO 10
- const#(k%,j%)=1
- NEXT j%
- NEXT k%
- n%(i%)=0
- ELSE
- PRINT AT(2,i_line%);" "
- GOSUB dec_val
- const#(type|,i%)=d_val#
- INC i%
- GOSUB findn
- ENDIF
- UNTIL n%(i%)=0
- RETURN
- PROCEDURE findn
- n%(i%)=INSTR(function$(type|,equat%(type|)),CHR$(64+i%))
- RETURN
- PROCEDURE prntfunct
- functlabel$=""
- n%(0)=0
- i%=1
- GOSUB findn
- REPEAT
- functlabel$=functlabel$+MID$(function$(type|,equat%(type|)),n%(i%-1)+1,n%(i%)-n%(i%-1)-1)+STR$(const#(type|,i%))
- INC i%
- GOSUB findn
- UNTIL n%(i%)=0
- functlabel$=functlabel$+MID$(function$(type|,equat%(type|)),n%(i%-1)+1,LEN(function$(type|,equat%(type|)))-n%(i%-1)+1)
- RETURN
- PROCEDURE getconst
- a#=const#(type|,1)
- b#=const#(type|,2)
- c#=const#(type|,3)
- d#=const#(type|,4)
- e#=const#(type|,5)
- f#=const#(type|,6)
- g#=const#(type|,7)
- h#=const#(type|,8)
- i#=const#(type|,9)
- j#=const#(type|,10)
- RETURN
- PROCEDURE discont_funct
- ' ********************-Discontinuous Function-*******************
- ' Do this if function returns an error
- funct_error!=TRUE
- ON ERROR GOSUB discont_funct
- RESUME NEXT
- RETURN
- PROCEDURE fnd_cont_pnt(theta#,dtheta#)
- ' $$$$$$$$$$$$$$-Find the limit of a discontinuity-$$$$$$$$$$$$$$
- ' Finds the exact point where a function moves from a continuous area to
- ' discontinuos and back so there are no unnecessary gaps. Only used by polar
- ' in this version. Sorry.
- REPEAT
- DIV dtheta#,2
- IF funct_error! !Did this point produce an error
- IF discont!=FALSE !Did we move from a continuous area to discontinuous
- SUB theta#,dtheta#
- ELSE ! Then we moved from a discontinuous to continuous area
- ADD theta#,dtheta#
- ENDIF
- ELSE !Must be a good point
- IF discont!=FALSE
- ADD theta#,dtheta#
- ELSE
- SUB theta#,dtheta#
- ENDIF
- ENDIF
- funct_error!=FALSE
- IF custom_funct!(type|)=TRUE
- var1#=theta#
- GOSUB evaluate
- IF NOT funct_error!
- r#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB pol0,pol1,pol2,pol3,pol4,pol5,pol6,pol7,pol8,pol9,pol10,pol11,pol12,pol13,pol14,pol15
- ENDIF
- UNTIL dtheta#<1E-09 !Do it until the error is insignificant
- IF funct_error! !Did the last point produce an error
- IF discont!=FALSE !Then change theta by the small increment to move to
- ' the continuous area of the curve
- SUB theta#,dtheta#
- ELSE
- ADD theta#,dtheta#
- ENDIF
- IF custom_funct!(type|)=TRUE
- var1#=theta#
- GOSUB evaluate
- IF NOT funct_error!
- r#=stack#(stack_ptr%)
- ENDIF
- ELSE
- ON equat%(type|)+1 GOSUB pol0,pol1,pol2,pol3,pol4,pol5,pol6,pol7,pol8,pol9,pol10,pol11,pol12,pol13,pol14,pol15
- ENDIF
- ENDIF
- y#=r#*SIN(theta#)
- z#=r#*COS(theta#)
- px#(i%,j%)=0
- py#(i%,j%)=z# !Turn it sideways to be conventional
- pz#(i%,j%)=y#
- IF r#>max_limit#(type|) OR r#<min_limit#(type|)
- pz#(i%,j%)=funct_error%
- ENDIF
- RETURN
- PROCEDURE custom_funct
- ' UFUFUFUFUFUFUFUFUFUFUFUFUFUF-User entered function-UFUFUFUFUFUFUFUFUFUFUFUFUF
- ' --Get the function--
- HIDEM
- cf!=TRUE
- PRINT
- IF type|=sphere|
- PRINT " ϕ=Control-s,m Θ=Control-s,i"
- ENDIF
- IF type|=cylin|
- PRINT " Θ=Control-s,i"
- ENDIF
- IF type|=polar|
- PRINT " Θ=Control-s,i"
- ENDIF
- PRINT AT(4,4);"Enter your function:"
- IF type|=rect|
- temp$="z="
- ELSE
- IF type|=cart|
- temp$="y="
- ELSE
- temp$="r="
- ENDIF
- ENDIF
- PRINT AT(4,6);temp$;
- FORM INPUT 255 AS cfunctlabel$(type|)
- RETURN
- PROCEDURE convert
- ' --Convert user function to postfix mode--
- lparen%=0
- rparen%=0
- syntax_error!=FALSE
- infix$=UPPER$(cfunctlabel$(type|))
- IF type|<>rect| OR type|<>cart|
- FOR i%=1 TO LEN(infix$)
- in_str$=MID$(infix$,i%,1)
- IF in_str$="("
- INC lparen%
- ENDIF
- IF in_str$=")"
- INC rparen%
- ENDIF
- IF type|=sphere|
- IF in_str$="ϕ"
- MID$(infix$,i%,1)="X"
- ENDIF
- IF in_str$="Θ"
- MID$(infix$,i%,1)="Y"
- ENDIF
- ENDIF
- IF type|=cylin|
- IF in_str$="Θ"
- MID$(infix$,i%,1)="X"
- ENDIF
- IF in_str$="Z"
- MID$(infix$,i%,1)="Y"
- ENDIF
- ENDIF
- IF type|=polar|
- IF in_str$="Θ"
- MID$(infix$,i%,1)="X"
- ENDIF
- ENDIF
- NEXT i%
- ENDIF
- IF rparen%<>lparen%
- PRINT AT(4,8);"◆Unmatched Parenthesis"
- syntax_error!=TRUE
- GOTO convert_end
- ENDIF
- infix_ptr%=1
- postfix$(type|)=""
- stack$=""
- n%=0
- number%=1
- stack_priority%(0)=0
- WHILE infix_ptr%<=LEN(infix$)
- token$=""
- INC n%
- in_str$=MID$(infix$,infix_ptr%,1)
- IF (ASC(in_str$)>47 AND ASC(in_str$)<58) OR in_str$="." !numbers 0-9 or decimal
- token$="O"
- priority%(n%)=0
- digit_ptr%=infix_ptr%
- REPEAT
- INC infix_ptr%
- in_str$=MID$(infix$,infix_ptr%,1)
- UNTIL (ASC(in_str$)<48 OR ASC(in_str$)>57) AND in_str$<>"."
- digits%=infix_ptr%-digit_ptr%-1
- temp$=MID$(infix$,digit_ptr%,digits%+1)
- GOSUB dec_val
- numer_val#(number%)=d_val#
- INC number%
- ELSE
- IF ASC(in_str$)>64 AND ASC(in_str$)<91 !letters A-Z
- IF in_str$="X" OR in_str$="Y"
- token$=CHR$(ASC(in_str$)-8)
- priority%(n%)=0
- INC infix_ptr%
- ELSE
- funct$=MID$(infix$,infix_ptr%,4)
- IF funct$="SIN("
- token$="G"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="COS("
- token$="H"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="EXP("
- token$="I"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="LOG("
- token$="J"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="SQR("
- token$="K"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="TAN("
- token$="L"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="ABS("
- token$="M"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- IF funct$="ATN("
- token$="N"
- priority%(n%)=5
- infix_ptr%=infix_ptr%+3
- ENDIF
- ENDIF
- ELSE
- IF in_str$="(" OR in_str$=")"
- token$=in_str$
- priority%(n%)=0
- ENDIF
- IF in_str$="+"
- token$="A"
- priority%(n%)=1
- ENDIF
- IF in_str$="-"
- IF MID$(infix$,infix_ptr%-1,1)="(" OR infix_ptr%=1
- priority%(n%)=3
- token$="B"
- ELSE
- priority%(n%)=1
- token$="C"
- ENDIF
- ENDIF
- IF in_str$="*"
- token$="D"
- priority%(n%)=2
- ENDIF
- IF in_str$="/"
- token$="E"
- priority%(n%)=2
- ENDIF
- IF in_str$="^"
- token$="F"
- priority%(n%)=4
- ENDIF
- INC infix_ptr%
- ENDIF
- ENDIF
- IF token$=""
- PRINT AT(4,8);"◆Syntax Error "
- syntax_error!=TRUE
- GOTO convert_end
- ENDIF
- IF token$="O" OR token$="P" OR token$="Q"
- postfix$(type|)=postfix$(type|)+token$
- ELSE
- IF token$="("
- stack$=stack$+token$
- stack_priority%(LEN(stack$))=priority%(n%)
- ELSE
- IF token$=")"
- WHILE RIGHT$(stack$)<>"("
- temp$=RIGHT$(stack$)
- postfix$(type|)=postfix$(type|)+temp$
- stack$=LEFT$(stack$,LEN(stack$)-1)
- WEND
- stack$=LEFT$(stack$,LEN(stack$)-1)
- ELSE
- WHILE priority%(n%)<=stack_priority%(LEN(stack$))
- postfix$(type|)=postfix$(type|)+RIGHT$(stack$)
- stack$=LEFT$(stack$,LEN(stack$)-1)
- WEND
- stack$=stack$+token$
- stack_priority%(LEN(stack$))=priority%(n%)
- ENDIF
- ENDIF
- ENDIF
- WEND
- WHILE LEN(stack$)>0
- token$=RIGHT$(stack$)
- postfix$(type|)=postfix$(type|)+token$
- stack$=LEFT$(stack$,LEN(stack$)-1)
- WEND
- postfix_ptr%=VARPTR(postfix$(type|))
- FOR i%=0 TO LEN(postfix$(type|))-1
- POKE postfix_ptr%+i%,PEEK(postfix_ptr%+i%)-64
- NEXT i%
- convert_end:
- RETURN
- PROCEDURE evaluate
- ' --Evaluate postfix function--
- postfix_ptr%=VARPTR(postfix$(type|))
- last_token%=postfix_ptr%+LEN(postfix$(type|))-1
- number%=0
- stack_ptr%=0
- REPEAT
- ON PEEK(postfix_ptr%) GOSUB a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q
- INC postfix_ptr%
- UNTIL postfix_ptr%>last_token%
- RETURN
- PROCEDURE a
- DEC stack_ptr%
- ADD stack#(stack_ptr%),stack#(stack_ptr%+1)
- RETURN
- PROCEDURE b
- stack#(stack_ptr%)=-(stack#(stack_ptr%))
- RETURN
- PROCEDURE c
- DEC stack_ptr%
- SUB stack#(stack_ptr%),stack#(stack_ptr%+1)
- RETURN
- PROCEDURE d
- DEC stack_ptr%
- MUL stack#(stack_ptr%),stack#(stack_ptr%+1)
- RETURN
- PROCEDURE e
- DEC stack_ptr%
- DIV stack#(stack_ptr%),stack#(stack_ptr%+1)
- RETURN
- PROCEDURE f
- DEC stack_ptr%
- stack#(stack_ptr%)=stack#(stack_ptr%)^stack#(stack_ptr%+1)
- RETURN
- PROCEDURE g
- stack#(stack_ptr%)=SIN(stack#(stack_ptr%))
- RETURN
- PROCEDURE h
- stack#(stack_ptr%)=COS(stack#(stack_ptr%))
- RETURN
- PROCEDURE i
- stack#(stack_ptr%)=EXP(stack#(stack_ptr%))
- RETURN
- PROCEDURE j
- stack#(stack_ptr%)=LOG(stack#(stack_ptr%))
- RETURN
- PROCEDURE k
- stack#(stack_ptr%)=SQR(stack#(stack_ptr%))
- RETURN
- PROCEDURE l
- stack#(stack_ptr%)=TAN(stack#(stack_ptr%))
- RETURN
- PROCEDURE m
- stack#(stack_ptr%)=ABS(stack#(stack_ptr%))
- RETURN
- PROCEDURE n
- stack#(stack_ptr%)=ATN(stack#(stack_ptr%))
- RETURN
- PROCEDURE o
- INC stack_ptr%
- INC number%
- stack#(stack_ptr%)=numer_val#(number%)
- RETURN
- PROCEDURE p
- INC stack_ptr%
- stack#(stack_ptr%)=var1#
- RETURN
- PROCEDURE q
- INC stack_ptr%
- stack#(stack_ptr%)=var2#
- RETURN
- PROCEDURE get_pattern
- MENU KILL
- MENU OFF
- ptrn|=0
- CLS
- temp$="Click on a fill pattern"
- TEXT rxf|*66,ryf|*7,temp$
- COLOR 1
- DEFFILL 2,2,1
- PRBOX rxf|*10,ryf|*10,rxf|*62,ryf|*95
- DEFFILL 2,2,2
- PRBOX rxf|*72,ryf|*10,rxf|*124,ryf|*95
- DEFFILL 2,2,3
- PRBOX rxf|*134,ryf|*10,rxf|*186,ryf|*95
- DEFFILL 2,2,4
- PRBOX rxf|*196,ryf|*10,rxf|*248,ryf|*95
- DEFFILL 2,2,5
- PRBOX rxf|*258,ryf|*10,rxf|*310,ryf|*95
- DEFFILL 2,2,6
- PRBOX rxf|*10,ryf|*105,rxf|*62,ryf|*190
- DEFFILL 2,2,7
- PRBOX rxf|*72,ryf|*105,rxf|*124,ryf|*190
- DEFFILL 2,2,8
- PRBOX rxf|*134,ryf|*105,rxf|*186,ryf|*190
- DEFFILL 2,2,15
- PRBOX rxf|*196,ryf|*105,rxf|*248,ryf|*190
- DEFFILL 2,0,0
- PRBOX rxf|*258,ryf|*105,rxf|*310,ryf|*190
- SHOWM
- DO
- dum%=MOUSEK
- IF dum%=1
- GOSUB pattern_value
- ENDIF
- EXIT IF dum%=1 AND ptrn|>0
- LOOP
- CLS
- PAUSE 10
- GOSUB param_menu
- RETURN
- PROCEDURE pattern_value
- ' Top row of boxes
- MOUSE micex&,micey&,dum%
- IF micey&>ryf|*11 AND micey&<ryf|*ryf|*95
- IF micex&>rxf|*10 AND micex&<rxf|*62
- ptrn|=1
- ENDIF
- IF micex&>rxf|*72 AND micex&<rxf|*124
- ptrn|=2
- ENDIF
- IF micex&>rxf|*134 AND micex&<rxf|*186
- ptrn|=3
- ENDIF
- IF micex&>rxf|*196 AND micex&<rxf|*248
- ptrn|=4
- ENDIF
- IF micex&>rxf|*258 AND micex&<rxf|*310
- ptrn|=5
- ENDIF
- ENDIF
- IF micey&>ryf|*105 AND micey&<ryf|*190
- IF micex&>rxf|*10 AND micex&<rxf|*62
- ptrn|=6
- ENDIF
- IF micex&>rxf|*72 AND micex&<rxf|*124
- ptrn|=7
- ENDIF
- IF micex&>rxf|*134 AND micex&<rxf|*186
- ptrn|=8
- ENDIF
- IF micex&>rxf|*196 AND micex&<rxf|*248
- ptrn|=15
- ENDIF
- IF micex&>rxf|*258 AND micex&<rxf|*310
- ptrn|=100
- ENDIF
- ENDIF
- RETURN
- PROCEDURE drw_grid
- IF demo|=on|
- IF yhi#-ylo#>7 OR zhi#-zlo#>5
- x_int#=1
- y_int#=1
- ELSE
- x_int#=0.5
- y_int#=0.5
- ENDIF
- ENDIF
- sx0#=-1
- sy0#=-1
- n%=0
- k%=0
- COLOR colrtable|(2)
- top_bottom!=TRUE
- qz1#=0
- GOSUB horiz_lines
- top_bottom!=FALSE
- GOSUB vert_lines
- GOSUB horiz_lines
- DEFTEXT colrtable|(1),0,0,4
- GOSUB horiz_line_lables
- DEFTEXT colrtable|(1),0,900,4
- GOSUB vert_line_lables
- RETURN
- PROCEDURE vert_lines
- qy1#=0
- qx#=0
- qz#=0
- qy#=qy1#
- GOSUB calcsxsy
- sx1#=sx#
- SUB qy1#,x_int#
- DEC n%
- qx#=0
- qz#=0
- qy#=qy1#
- GOSUB calcsxsy
- sx_int#=ABS(sx1#-sx#)
- REPEAT
- DEC n%
- SUB sx#,sx_int#
- SUB qy1#,x_int#
- UNTIL sx#<0
- first!=FALSE
- y%(0)=top%
- y%(1)=bottom%
- REPEAT
- IF qy1#>-0.1*x_int# AND qy1#<0.1*x_int#
- COLOR colrtable|(2)
- sx0#=sx#
- ELSE
- COLOR colrtable|(3)
- ENDIF
- IF sx#>0 AND sx#<max_sx&
- IF first!=FALSE
- left%=sx#
- first!=TRUE
- ENDIF
- x%(0)=sx#
- x%(1)=sx#
- right%=sx#
- POLYLINE 2,x%(),y%()
- IF n%<>0
- ENDIF
- ENDIF
- ADD qy1#,x_int#
- ADD sx#,sx_int#
- INC n%
- UNTIL sx#>max_sx&
- ' save last sx for lables
- sx1#=sx#
- RETURN
- PROCEDURE horiz_lines
- qz1#=0
- qx#=0
- qy#=0
- qz#=qz1#
- GOSUB calcsxsy
- sy1#=sy#
- SUB qz1#,y_int#
- DEC k%
- qx#=0
- qy#=0
- qz#=qz1#
- GOSUB calcsxsy
- sy_int#=ABS(sy1#-sy#)
- REPEAT
- DEC k%
- ADD sy#,sy_int#
- SUB qz1#,y_int#
- UNTIL sy#>max_sy&
- first!=FALSE
- x%(0)=left%
- x%(1)=right%
- REPEAT
- IF qz1#>-0.1*y_int# AND qz1#<0.1*y_int#
- sy0#=sy#
- COLOR colrtable|(2)
- ELSE
- COLOR colrtable|(3)
- ENDIF
- IF sy#<max_sy& AND sy#>0
- IF first!=FALSE
- bottom%=sy#
- first!=TRUE
- ENDIF
- y%(0)=sy#
- y%(1)=sy#
- top%=sy#
- IF top_bottom!=FALSE
- POLYLINE 2,x%(),y%()
- ENDIF
- ENDIF
- INC k%
- ADD qz1#,y_int#
- SUB sy#,sy_int#
- UNTIL sy#<0
- RETURN
- PROCEDURE horiz_line_lables
- REPEAT
- ADD sy#,sy_int#
- SUB qz1#,y_int#
- IF sx0#>-1 AND sx0#<max_sx&
- TEXT sx0#+2,sy#,STR$(qz1#)
- ELSE
- TEXT left%,sy#,STR$(qz1#)
- ENDIF
- UNTIL sy#+1>bottom%
- RETURN
- PROCEDURE vert_line_lables
- sx#=sx1#
- REPEAT
- DEC n%
- SUB sx#,sx_int#
- SUB qy1#,x_int#
- IF (NOT sx#==sx0#)
- IF trig!=FALSE
- IF sy0#>-1 AND sy0#<max_sy&
- TEXT sx#,sy0#-2,STR$(qy1#)
- ELSE
- TEXT sx#,bottom%,STR$(qy1#)
- ENDIF
- ELSE
- GOSUB trig_labels
- ENDIF
- ENDIF
- UNTIL sx#-1<left%
- RETURN
- PROCEDURE trig_labels
- ' π=Control s,c
- IF EVEN(n%)=TRUE
- IF EVEN(n%/2)
- temp$=STR$(n%/4)+"π"
- ELSE
- temp$=STR$(n%/2)+"π/2"
- ENDIF
- IF n%=2
- temp$="π/2"
- ENDIF
- IF n%=4
- temp$="π"
- ENDIF
- IF n%=-2
- temp$="-π/2"
- ENDIF
- IF n%=-4
- temp$="-π"
- ENDIF
- IF sy0#>-1 AND sy0#<max_sy&
- TEXT sx#,sy0#-2,temp$
- ELSE
- TEXT sx#,bottom%,temp$
- ENDIF
- ENDIF
- RETURN
- PROCEDURE cad3d_save
- ' c3dc3dc3dc3dc3dc3dc3dc3dc3d-CAD3D SAVE-c3dc3dc3dc3dc3dc3dc3dc3d
- scale_factor#=15/MAX(xhi#,ABS(xlo#),yhi#,ABS(ylo#),zhi#,ABS(zlo#)) !scale factor to make objects a good size
- MUL scale_factor#,100
- RESTORE caddat
- pnt_no%=0
- cad3d_dat$=STRING$(8033," ") !create a buffer
- strpntr%=VARPTR(cad3d_dat$) !pointer to buffer
- ' read light and color data
- FOR i%=0 TO 51
- READ j%
- DPOKE strpntr%,j%
- ADD strpntr%,2
- NEXT i%
- ' fill in empty space with zeros
- REPEAT
- DPOKE strpntr%,0
- ADD strpntr%,2
- UNTIL strpntr%=VARPTR(cad3d_dat$)+258
- ' insert object name
- MID$(cad3d_dat$,257,9)=o_name$
- BPUT #1,VARPTR(cad3d_dat$),265
- ' remember this spot in file to put the vertice count
- f_pointer%=LOC(#1)
- strpntr%=VARPTR(cad3d_dat$)+2 !leave space for vcount
- buffer%=2
- FOR i%=0 TO pntint_x%(type|)
- FOR j%=0 TO pntint_y%(type|)
- pnt_repeat!=FALSE
- first_to_last!=FALSE
- IF pz#(i%,j%)<>funct_error%! check for function error and leave those points out
- k%=TRUNC((px#(i%,j%)-fx#)*scale_factor#)
- l%=TRUNC((py#(i%,j%)-fy#)*scale_factor#)
- m%=TRUNC((pz#(i%,j%)-fz#)*scale_factor#)
- IF j%<>0
- ' if this point is the same as the last one set a flag
- IF k%=TRUNC(px#(i%,j%-1)*scale_factor#) AND l%=TRUNC(py#(i%,j%-1)*scale_factor#) AND m%=TRUNC(pz#(i%,j%-1)*scale_factor#)
- pnt_repeat!=TRUE
- ENDIF
- ' if the end point of this line is the same as the last point set a flag
- IF j%=pntint_y%(type|) AND (k%=TRUNC(px#(i%,0)*scale_factor#) AND l%=TRUNC(py#(i%,0)*scale_factor#) AND m%=TRUNC(pz#(i%,0)*scale_factor#))
- first_to_last!=TRUE
- ENDIF
- ENDIF
- ' if neither flag set, include the point
- IF pnt_repeat!=FALSE AND first_to_last!=FALSE
- pnt_no%(i%*(pntint_y%(type|)+1)+j%)=pnt_no%
- DPOKE strpntr%,k%
- ADD strpntr%,2
- DPOKE strpntr%,l%
- ADD strpntr%,2
- DPOKE strpntr%,m%
- ADD strpntr%,2
- ADD buffer%,6
- IF buffer%>8000
- BPUT #1,VARPTR(cad3d_dat$),buffer%
- strpntr%=VARPTR(cad3d_dat$)
- buffer%=0
- ENDIF
- INC pnt_no% ! increase point number since this is a new point
- ENDIF
- IF first_to_last!
- ' make last point in this line same as first in the line
- pnt_no%(i%*(pntint_y%(type|)+1)+j%)=pnt_no%(i%*(pntint_y%(type|)+1))
- ELSE
- ' record the point number
- pnt_no%(i%*(pntint_y%(type|)+1)+j%)=pnt_no%-1
- ENDIF
- ENDIF
- NEXT j%
- NEXT i%
- BPUT #1,VARPTR(cad3d_dat$),buffer% !empty the buffer
- vcount%=pnt_no%
- f_pointer1%=LOC(#1) !remember where we were in the file
- DPOKE VARPTR(cad3d_dat$),vcount%
- SEEK #1,f_pointer% !go back in the file and record vcount
- BPUT #1,VARPTR(cad3d_dat$),2
- SEEK #1,f_pointer1% !reset file pointer
- strpntr%=VARPTR(cad3d_dat$)
- buffer%=0
- f_pointer%=LOC(#1) !remember this spot for face count
- ADD strpntr%,2
- ADD buffer%,2 !leave room for face count
- face_count%=0
- FOR i%=0 TO pntint_x%(type|)-1
- FOR j%=0 TO pntint_y%(type|)-1
- IF pz#(i%,j%)<>funct_error% AND pz#(i%,j%+1)<>funct_error% AND pz#(i%+1,j%)<>funct_error% AND pz#(i%+1,j%+1)<>funct_error%
- k%=i%*(pntint_y%(type|)+1)+j%
- l%=k%+1
- m%=l%+pntint_y%(type|)
- n%=m%+1
- IF side1!
- GOSUB side1
- ENDIF
- IF side2!
- GOSUB side2
- ENDIF
- ENDIF
- IF buffer%>8000
- BPUT #1,VARPTR(cad3d_dat$),buffer%
- strpntr%=VARPTR(cad3d_dat$)
- buffer%=0
- ENDIF
- NEXT j%
- NEXT i%
- BPUT #1,VARPTR(cad3d_dat$),buffer%
- DPOKE VARPTR(cad3d_dat$),face_count%
- SEEK #1,f_pointer% !go back and record the face count
- BPUT #1,VARPTR(cad3d_dat$),2
- CLOSE #1
- caddat:
- DATA &3D02,&0001,&0001,&0000,&0000,&0007,&0004,&0003,&0000,&0040,&FFCE,&0000,&0004,&0032,&FFCE,&003D,&FFCE
- DATA &0000,&0000,&0101,&0202,&0303,&0404,&0505,&0606,&0707,&0717,&0727,&0737,&0747,&0757,&0767,&0777,&0777
- DATA &0000,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&0001,&000F,&0001,&000F
- RETURN
- PROCEDURE side1
- ' check to see if all four points are different
- IF pnt_no%(k%)<>pnt_no%(l%) AND pnt_no%(m%)<>pnt_no%(n%)
- front: !front side
- begindoub:
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(l%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,&H608
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(m%)
- ADD strpntr%,2
- DPOKE strpntr%,&H308
- ADD strpntr%,2
- ADD face_count%,2
- ADD buffer%,16
- enddoub:
- ELSE !if two points are the same make it just a triangle
- begdoub1:
- IF pnt_no%(m%)=pnt_no%(n%)
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(l%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,&H708
- ADD strpntr%,2
- ELSE
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(m%)
- ADD strpntr%,2
- DPOKE strpntr%,&H708
- ADD strpntr%,2
- ENDIF
- enddoub1:
- INC face_count%
- ADD buffer%,8
- ENDIF
- RETURN
- PROCEDURE side2
- IF pnt_no%(k%)<>pnt_no%(l%) AND pnt_no%(m%)<>pnt_no%(n%)
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(m%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,&H608
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(l%)
- ADD strpntr%,2
- DPOKE strpntr%,&H308
- ADD strpntr%,2
- ADD face_count%,2
- ADD buffer%,16
- ELSE !if two points are the same make it just a triangle
- IF pnt_no%(k%)=pnt_no%(l%)
- front1:
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(m%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,&H708
- ADD strpntr%,2
- ELSE
- DPOKE strpntr%,pnt_no%(k%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(n%)
- ADD strpntr%,2
- DPOKE strpntr%,pnt_no%(l%)
- ADD strpntr%,2
- DPOKE strpntr%,&H708
- ADD strpntr%,2
- ENDIF
- INC face_count%
- ADD buffer%,8
- ENDIF
- RETURN
- PROCEDURE rec0
- ' RFRFRFRFRFRFRFRFRF-Rectangular Functions-RFRFRFRFRFRFRFRFRFRFRF
- ' Rectangular
- z#=(a#*x#*x#+b#*y#*y#)*EXP(1-c#*x#*x#-d#*y#*y#)
- RETURN
- PROCEDURE rec1
- z#=a#/SQR(b#+x#*x#+y#*y#)*COS(SQR(c#*y#*y#+d#*x#*x#))
- RETURN
- PROCEDURE rec2
- z#=(a#*x#*y#)^(1/b#)
- RETURN
- PROCEDURE rec3
- z#=a#*SIN(b#*x#)+c#*COS(d#*y#)
- RETURN
- PROCEDURE rec4
- z#=a#*COS(b#*x#*c#*y#)
- RETURN
- PROCEDURE rec5
- z#=a#*(EXP(b#*SIN(c#*x#*d#*y#)))
- RETURN
- PROCEDURE rec6
- z#=a#*(ABS(b#*COS(c#*x#)+d#*COS(e#*y#)))
- RETURN
- PROCEDURE rec7
- z#=a#*(SQR(b#*x#^c#+d#*y#^e#))
- RETURN
- PROCEDURE rec8
- z#=1/(a#+x#*x#+y#*y#)-1/(b#+x#*x#+(y#-2)*(y#-2))
- RETURN
- PROCEDURE rec9
- z#=(x#*x#*COS(a#*x#)+y#*y#*b#*SIN(c#*y#))*EXP(1-x#*x#-y#*y#)
- RETURN
- PROCEDURE rec10
- z#=a#*LOG(ABS(b#*x#))+c#*LOG(ABS(d#*y#))
- RETURN
- PROCEDURE rec11
- z#=SIN(a#*x#)*COS(b#*y#)
- RETURN
- PROCEDURE rec12
- z#=a#*COS(SQR(b#*x#*x#+c#*y#*y#))+d#*COS(x#)
- RETURN
- PROCEDURE sph0
- ' SFSFSFSFSFSFSFSFSF-Spherical Functions-SFSFSFSFSFSFSFSFSFSFSFSF
- r#=a#+b#*SQR(c#*COS(d#*phi#))
- RETURN
- PROCEDURE sph1
- r#=a#+b#*SIN(c#*phi#/d#)
- RETURN
- PROCEDURE sph2
- r#=a#+b#*SQR(c#*phi#)
- RETURN
- PROCEDURE sph3
- r#=a#+b#/COS(phi#)
- RETURN
- PROCEDURE sph4
- r#=a#+b#*SIN(c#*theta#)
- RETURN
- PROCEDURE sph5
- r#=a#*SIN(b#*phi#)+c#*COS(d#*theta#)
- RETURN
- PROCEDURE sph6
- r#=a#*SIN(b#*phi#)/(c#*COS(phi#)+1)
- RETURN
- PROCEDURE sph7
- r#=a#*SIN(b#*phi#)+c#*COS(d#*phi#)+e#
- RETURN
- PROCEDURE sph8
- r#=a#/(b#-c#*COS(d#*(phi#)))+e#
- RETURN
- PROCEDURE sph9
- r#=a#/(b#-c#*SIN(d#*(phi#)))+e#
- RETURN
- PROCEDURE sph10
- r#=a#*SIN(b#*theta#)+c#*COS(d#*phi#)
- RETURN
- PROCEDURE sph11
- r#=a#*SIN(EXP(phi#))+b#*COS(EXP(phi#))
- RETURN
- PROCEDURE sph12
- r#=a#*phi#+b#*theta#
- RETURN
- PROCEDURE cyl0
- ' CFCFCFCFCFCFCFCFCF-Cylindrical Functions-CFCFCFCFCFCFCFCFCFCFCF
- r#=a#+b#*COS(c#*theta#)+d#*SIN(e#*theta#)
- RETURN
- PROCEDURE cyl1
- r#=a#/(b#-c#*COS(d#*theta#))+e#
- RETURN
- PROCEDURE cyl2
- r#=a#*SIN(b#*theta#)+c#*COS(d#*theta#)+e#*z#
- RETURN
- PROCEDURE cyl3
- r#=a#+b#*SIN(c#*theta#)*COS(d#*theta#)
- RETURN
- PROCEDURE cyl4
- r#=a#+b#*TAN(c#*theta#)
- RETURN
- PROCEDURE cyl5
- r#=a#+b#*SIN(c#*theta#)*COS(d#*theta#)*COS(d#*theta#)
- RETURN
- PROCEDURE cyl6
- r#=a#+b#*z#-c#*SIN(d#*z#)
- RETURN
- PROCEDURE cyl7
- r#=a#*z#*z#+b#*z#+c#
- RETURN
- PROCEDURE cyl8
- r#=a#/z#*z#+b#/z#+c#
- RETURN
- PROCEDURE cyl9
- r#=a#+b#*z#+c#*z#*COS(d#*theta#)
- RETURN
- PROCEDURE cyl10
- r#=SIN(a#*z#)*COS(b#*theta#)
- RETURN
- PROCEDURE car0
- ' cfcfcfcfcfcfcfcfcfcfcf-Cartesian Functions-cfcfcfcfcfcfcfcfcfcf
- y#=a#*x#*x#*x#+b#*x#*x#+c#*x#+d#
- RETURN
- PROCEDURE car1
- y#=(a#/SQR(2*PI))*EXP(-x#*x#/2)
- RETURN
- PROCEDURE car2
- y#=x#/a#+x#^b#-x#^c#
- RETURN
- PROCEDURE car3
- y#=a#+b#*SIN(c#*x#)+d#*x#*(SIN(e#*x#))
- RETURN
- PROCEDURE car4
- y#=a#+b#*COS(c#*x#)+d#*x#*(COS(e#*x#))
- RETURN
- PROCEDURE car5
- y#=a#+b#*TAN(c#*x#)+d#*x#*(TAN(e#*x#))
- RETURN
- PROCEDURE car6
- y#=a#+b#*1/COS(c#*x#)+d#*x#*1/COS(e#*x#)
- RETURN
- PROCEDURE car7
- y#=a#+b#*SIN(c#*x#)+d#*x#*(COS(e#*x#))
- RETURN
- PROCEDURE car8
- y#=a#+b#*(EXP(x#)-EXP(-x#))/2+c#*(EXP(x#)+EXP(-x#))/2
- RETURN
- PROCEDURE car9
- y#=a#*SQR(b#*b#-x#*x#)
- RETURN
- PROCEDURE car10
- y#=(a#*x#-2)^3/(b#*x#*x#)
- RETURN
- PROCEDURE car11
- y#=a#*x#*x#/EXP(b#*x#)
- RETURN
- PROCEDURE car12
- y#=COS(a#*x#)*EXP(x#/b#)
- RETURN
- PROCEDURE car13
- y#=a#*x#*x#*x#*EXP(-x#/b#)
- RETURN
- PROCEDURE car14
- y#=a#*x#/((b#*x#+c#)*(b#*x#+c#))
- RETURN
- PROCEDURE car15
- y#=a#*ATN(x#)
- RETURN
- PROCEDURE pol0
- ' PFPFPFPFPFPFPFPFPFPFPFPF-Polar Functions-PFPFPFPFPFPFPFPFPFPFPF
- r#=a#+b#*COS(c#*theta#)+d#*SIN(e#*theta#)
- RETURN
- PROCEDURE pol1
- r#=a#+b#*SQR(c#*COS(d#*theta#))
- RETURN
- PROCEDURE pol2
- r#=a#/(b#-c#*COS(d#*theta#))+e#
- RETURN
- PROCEDURE pol3
- r#=a#/(b#-c#*SIN(d#*theta#))+e#
- RETURN
- PROCEDURE pol4
- r#=a#+b#*TAN(c#*theta#)
- RETURN
- PROCEDURE pol5
- r#=a#+b#*SIN(c#*theta#)*TAN(d#*theta#)
- RETURN
- PROCEDURE pol6
- r#=a#/theta#
- RETURN
- PROCEDURE pol7
- r#=a#+b#*SIN(c#*theta#)*COS(d#*theta#)
- RETURN
- PROCEDURE pol8
- r#=a#+b#/SIN(c#*theta#)
- RETURN
- PROCEDURE pol9
- r#=a#+b#*SIN(c#*theta#)*COS(d#*theta#)*COS(d#*theta#)
- RETURN
-